mirror of https://github.com/procxx/kepka.git
				
				
				
			Fix updates of mute status in context menu of dialog list
Signed-off-by: Nicholas Guriev <guriev-ns@ya.ru>
This commit is contained in:
		
							parent
							
								
									7bcb6d556f
								
							
						
					
					
						commit
						a2c93bc040
					
				|  | @ -2248,16 +2248,17 @@ void MainWidget::fillPeerMenu(PeerData *peer, base::lambda<QAction*(const QStrin | ||||||
| 		Ui::showPeerProfile(peer); | 		Ui::showPeerProfile(peer); | ||||||
| 	}); | 	}); | ||||||
| 	auto muteSubscription = MakeShared<base::Subscription>(); | 	auto muteSubscription = MakeShared<base::Subscription>(); | ||||||
| 	QAction *muteAction; |     auto muteAction = callback(!peer->isMuted() ? lang(lng_disable_notifications_from_tray) : lang(lng_enable_notifications_from_tray), [peer, muteSubscription] { | ||||||
|  | 		// We have to capture the muteSubscription pointer in this lambda for
 | ||||||
|  | 		// real time updates of the action when an user changes mute status of
 | ||||||
|  | 		// the peer on his (her) another device. Otherwise, the subscription
 | ||||||
|  | 		// will be destroyed ahead of time.
 | ||||||
| 		if (!peer->isMuted()) { | 		if (!peer->isMuted()) { | ||||||
| 		muteAction = callback(lang(lng_disable_notifications_from_tray), [peer] { |  | ||||||
| 			Ui::show(Box<MuteSettingsBox>(peer)); | 			Ui::show(Box<MuteSettingsBox>(peer)); | ||||||
| 		}); |  | ||||||
| 		} else { | 		} else { | ||||||
| 		muteAction = callback(lang(lng_enable_notifications_from_tray), [peer] { |  | ||||||
| 			App::main()->updateNotifySetting(peer, NotifySettingSetNotify); | 			App::main()->updateNotifySetting(peer, NotifySettingSetNotify); | ||||||
| 		}); |  | ||||||
| 		} | 		} | ||||||
|  | 	}); | ||||||
| 	auto muteChangedHandler = Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::NotificationsEnabled, [muteAction, peer](const Notify::PeerUpdate &update) { | 	auto muteChangedHandler = Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::NotificationsEnabled, [muteAction, peer](const Notify::PeerUpdate &update) { | ||||||
| 		if (update.peer != peer) return; | 		if (update.peer != peer) return; | ||||||
| 		muteAction->setText(lang(peer->isMuted() ? lng_enable_notifications_from_tray : lng_disable_notifications_from_tray)); | 		muteAction->setText(lang(peer->isMuted() ? lng_enable_notifications_from_tray : lng_disable_notifications_from_tray)); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue