2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Fix local folders exceptions

This commit is contained in:
RadRussianRus
2020-12-29 01:37:48 +03:00
parent 31fd8f3d55
commit b1277c3d59
3 changed files with 9 additions and 45 deletions

View File

@@ -68,14 +68,12 @@ ChatFilter ChatFilter::local(
if (filterPeer.type == LocalFolder::Peer::Type::User) {
const auto user = owner->user(filterPeer.id);
user->setAccessHash(filterPeer.accessHash);
peer = (PeerData *)user;
} else if (filterPeer.type == LocalFolder::Peer::Type::Chat) {
const auto chat = owner->chat(filterPeer.id);
peer = (PeerData *)chat;
} else if (filterPeer.type == LocalFolder::Peer::Type::Channel) {
const auto channel = owner->channel(filterPeer.id);
channel->setAccessHash(filterPeer.accessHash);
peer = (PeerData *)channel;
}
return peer ? owner->history(peer).get() : nullptr;
@@ -233,8 +231,7 @@ LocalFolder ChatFilter::toLocal(int cloudOrder, FilterId replaceId) const {
: history->peer->isChat()
? LocalFolder::Peer::Type::Chat
: LocalFolder::Peer::Type::User,
.id = peerToBareInt(peer->id),
.accessHash = hash
.id = peerToBareInt(peer->id)
});
always.remove(history);
}
@@ -254,8 +251,7 @@ LocalFolder ChatFilter::toLocal(int cloudOrder, FilterId replaceId) const {
: history->peer->isChat()
? LocalFolder::Peer::Type::Chat
: LocalFolder::Peer::Type::User,
.id = peerToBareInt(peer->id),
.accessHash = hash
.id = peerToBareInt(peer->id)
});
}
auto never = std::vector<LocalFolder::Peer>();
@@ -274,8 +270,7 @@ LocalFolder ChatFilter::toLocal(int cloudOrder, FilterId replaceId) const {
: history->peer->isChat()
? LocalFolder::Peer::Type::Chat
: LocalFolder::Peer::Type::User,
.id = peerToBareInt(peer->id),
.accessHash = hash
.id = peerToBareInt(peer->id)
});
}
const auto &session = App::main()->session();

View File

@@ -328,9 +328,6 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
auto peerObj = QJsonObject();
peerObj.insert(qsl("type"), peerTypeToStr(peer.type));
peerObj.insert(qsl("id"), peer.id);
if (peer.accessHash != 0) {
peerObj.insert(qsl("hash"), QString::number(peer.accessHash));
}
folderNever << peerObj;
}
folderObject.insert(qsl("never"), folderNever);
@@ -340,9 +337,6 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
auto peerObj = QJsonObject();
peerObj.insert(qsl("type"), peerTypeToStr(peer.type));
peerObj.insert(qsl("id"), peer.id);
if (peer.accessHash != 0) {
peerObj.insert(qsl("hash"), QString::number(peer.accessHash));
}
folderPinned << peerObj;
}
folderObject.insert(qsl("pinned"), folderPinned);
@@ -352,9 +346,6 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
auto peerObj = QJsonObject();
peerObj.insert(qsl("type"), peerTypeToStr(peer.type));
peerObj.insert(qsl("id"), peer.id);
if (peer.accessHash != 0) {
peerObj.insert(qsl("hash"), QString::number(peer.accessHash));
}
folderAlways << peerObj;
}
folderObject.insert(qsl("always"), folderAlways);
@@ -806,9 +797,9 @@ bool Manager::readCustomFile() {
}
auto isPeerTypeRead = ReadStringOption(peer, "type", [&](auto type) {
peerStruct.type = QString::compare(type.toLower(), "channel")
peerStruct.type = (QString::compare(type.toLower(), "channel") == 0)
? LocalFolder::Peer::Type::Channel
: QString::compare(type.toLower(), "chat")
: (QString::compare(type.toLower(), "chat") == 0)
? LocalFolder::Peer::Type::Chat
: LocalFolder::Peer::Type::User;
});
@@ -817,13 +808,6 @@ bool Manager::readCustomFile() {
peerStruct.type = LocalFolder::Peer::Type::User;
}
ReadStringOption(peer, "hash", [&](auto hashString) {
const auto hash = hashString.toULongLong();
if (hash) {
peerStruct.accessHash = hash;
}
});
folderStruct.never.push_back(peerStruct);
}
});
@@ -846,9 +830,9 @@ bool Manager::readCustomFile() {
}
auto isPeerTypeRead = ReadStringOption(peer, "type", [&](auto type) {
peerStruct.type = QString::compare(type.toLower(), "channel")
peerStruct.type = (QString::compare(type.toLower(), "channel") == 0)
? LocalFolder::Peer::Type::Channel
: QString::compare(type.toLower(), "chat")
: (QString::compare(type.toLower(), "chat") == 0)
? LocalFolder::Peer::Type::Chat
: LocalFolder::Peer::Type::User;
});
@@ -857,13 +841,6 @@ bool Manager::readCustomFile() {
peerStruct.type = LocalFolder::Peer::Type::User;
}
ReadStringOption(peer, "hash", [&](auto hashString) {
const auto hash = hashString.toULongLong();
if (hash) {
peerStruct.accessHash = hash;
}
});
folderStruct.pinned.push_back(peerStruct);
}
});
@@ -886,9 +863,9 @@ bool Manager::readCustomFile() {
}
auto isPeerTypeRead = ReadStringOption(peer, "type", [&](auto type) {
peerStruct.type = QString::compare(type.toLower(), "channel")
peerStruct.type = (QString::compare(type.toLower(), "channel") == 0)
? LocalFolder::Peer::Type::Channel
: QString::compare(type.toLower(), "chat")
: (QString::compare(type.toLower(), "chat") == 0)
? LocalFolder::Peer::Type::Chat
: LocalFolder::Peer::Type::User;
});
@@ -897,13 +874,6 @@ bool Manager::readCustomFile() {
peerStruct.type = LocalFolder::Peer::Type::User;
}
ReadStringOption(peer, "hash", [&](auto hashString) {
const auto hash = hashString.toULongLong();
if (hash) {
peerStruct.accessHash = hash;
}
});
folderStruct.always.push_back(peerStruct);
}
});

View File

@@ -146,7 +146,6 @@ struct LocalFolder {
Type type;
int32 id;
uint64 accessHash = 0;
inline bool operator==(const Peer& other) {
return type == other.type