fix: a couple of crashes

fix: disable peer ids again
This commit is contained in:
ZavaruKitsu 2024-02-18 21:30:48 +03:00
parent 77d129a738
commit b8dda54e04
4 changed files with 13 additions and 5 deletions

View file

@ -775,7 +775,9 @@ FilterId ChatFilters::defaultId() const {
}
FilterId ChatFilters::lookupId(int index) const {
Expects(index >= 0 && index < _list.size());
if (index >= 0 && index < _list.size()) {
return FilterId(); // AyuGram: fix crash when using `hideAllChatsFolder`
}
if (_owner->session().user()->isPremium() || !_list.front().id()) {
return _list[index].id();

View file

@ -4258,7 +4258,9 @@ void Session::registerItemView(not_null<ViewElement*> view) {
}
void Session::unregisterItemView(not_null<ViewElement*> view) {
Expects(!_heavyViewParts.contains(view));
if (!_heavyViewParts.contains(view)) {
return; // AyuGram: fix crash when using `saveDeletedMessages`
}
_shownSpoilers.remove(view);

View file

@ -81,6 +81,7 @@ base::options::toggle ShowPeerIdBelowAbout({
.id = kOptionShowPeerIdBelowAbout,
.name = "Show Peer IDs in Profile",
.description = "Show peer IDs from API below their Bio / Description.",
.scope = static_cast<base::options::details::ScopeFlag>(0),
});
[[nodiscard]] rpl::producer<TextWithEntities> UsernamesSubtext(

View file

@ -256,9 +256,12 @@ void FiltersMenu::refresh() {
_scroll.scrollToY(oldTop);
// Fix active chat folder when hide all chats is enabled.
if (settings->hideAllChatsFolder) {
const auto lookup_id = filters->lookupId(premium() ? 0 : 1);
_session->setActiveChatsFilter(lookup_id);
// Also check for session content existance, because it may be null
// and there will be an exception in `Window::SessionController::showPeerHistory`
// because `SessionController::content()` == nullptr
if (settings->hideAllChatsFolder && _session->widget()->sessionContent()) {
const auto lookupId = filters->lookupId(premium() ? 0 : 1);
_session->setActiveChatsFilter(lookupId);
}
}