mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Return not_null<History*> in App::history().
This commit is contained in:
@@ -589,7 +589,7 @@ History *Histories::find(const PeerId &peerId) {
|
||||
return (i == map.cend()) ? 0 : i.value();
|
||||
}
|
||||
|
||||
History *Histories::findOrInsert(const PeerId &peerId) {
|
||||
not_null<History*> Histories::findOrInsert(const PeerId &peerId) {
|
||||
auto i = map.constFind(peerId);
|
||||
if (i == map.cend()) {
|
||||
auto history = peerIsChannel(peerId) ? static_cast<History*>(new ChannelHistory(peerId)) : (new History(peerId));
|
||||
@@ -598,7 +598,7 @@ History *Histories::findOrInsert(const PeerId &peerId) {
|
||||
return i.value();
|
||||
}
|
||||
|
||||
History *Histories::findOrInsert(const PeerId &peerId, int32 unreadCount, int32 maxInboxRead, int32 maxOutboxRead) {
|
||||
not_null<History*> Histories::findOrInsert(const PeerId &peerId, int32 unreadCount, int32 maxInboxRead, int32 maxOutboxRead) {
|
||||
auto i = map.constFind(peerId);
|
||||
if (i == map.cend()) {
|
||||
auto history = peerIsChannel(peerId) ? static_cast<History*>(new ChannelHistory(peerId)) : (new History(peerId));
|
||||
@@ -2099,6 +2099,21 @@ const ChannelHistory *History::asChannelHistory() const {
|
||||
return isChannel() ? static_cast<const ChannelHistory*>(this) : 0;
|
||||
}
|
||||
|
||||
not_null<History*> History::migrateToOrMe() const {
|
||||
if (auto to = peer->migrateTo()) {
|
||||
return App::history(to);
|
||||
}
|
||||
// We could get it by App::history(peer), but we optimize.
|
||||
return const_cast<History*>(this);
|
||||
}
|
||||
|
||||
History *History::migrateFrom() const {
|
||||
if (auto from = peer->migrateFrom()) {
|
||||
return App::history(from);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool History::isDisplayedEmpty() const {
|
||||
return isEmpty() || ((blocks.size() == 1) && blocks.front()->items.size() == 1 && blocks.front()->items.front()->isEmpty());
|
||||
}
|
||||
|
Reference in New Issue
Block a user