mirror of https://github.com/procxx/kepka.git
Fix crash in theme changing.
This commit is contained in:
parent
9ca4f0975a
commit
42798d466f
|
@ -99,8 +99,11 @@ inline bool IsSelfPeer(PeerData *peer) {
|
||||||
return (peer && peer->isSelf());
|
return (peer && peer->isSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int UnreadCount(PeerData *peer) {
|
inline int UnreadCount(not_null<PeerData*> peer) {
|
||||||
return (peer && peer->owner().history(peer->id)->unreadCountForBadge());
|
if (const auto history = peer->owner().historyLoaded(peer)) {
|
||||||
|
return history->unreadCountForBadge();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *FormatTime(int time) {
|
NSString *FormatTime(int time) {
|
||||||
|
@ -259,7 +262,8 @@ void SendKeyEvent(int command) {
|
||||||
std::move(
|
std::move(
|
||||||
themeChanged
|
themeChanged
|
||||||
) | rpl::filter([=](const Update &update) {
|
) | rpl::filter([=](const Update &update) {
|
||||||
return update.type == Update::Type::ApplyingTheme
|
return (update.type == Update::Type::ApplyingTheme)
|
||||||
|
&& (_peer != nullptr)
|
||||||
&& (UnreadCount(_peer) || Data::IsPeerAnOnlineUser(_peer));
|
&& (UnreadCount(_peer) || Data::IsPeerAnOnlineUser(_peer));
|
||||||
}) | rpl::start_with_next([=] {
|
}) | rpl::start_with_next([=] {
|
||||||
[self updateBadge];
|
[self updateBadge];
|
||||||
|
@ -286,8 +290,8 @@ void SendKeyEvent(int command) {
|
||||||
if (_peer == newPeer) {
|
if (_peer == newPeer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_peer = newPeer;
|
|
||||||
_peerChangedLifetime.destroy();
|
_peerChangedLifetime.destroy();
|
||||||
|
_peer = newPeer;
|
||||||
if (!_peer) {
|
if (!_peer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue