mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-01 12:00:48 +00:00
Refresh wallpaper file references.
This commit is contained in:
parent
466c6da5e3
commit
e59a68cd68
@ -2829,6 +2829,8 @@ void ApiWrap::refreshFileReference(
|
||||
request(
|
||||
MTPmessages_GetSavedGifs(MTP_int(0)),
|
||||
[] { crl::on_main([] { Local::writeSavedGifs(); }); });
|
||||
}, [&](Data::FileOriginWallpapers data) {
|
||||
request(MTPaccount_GetWallPapers(MTP_int(0)));
|
||||
}, [&](std::nullopt_t) {
|
||||
fail();
|
||||
});
|
||||
|
@ -52,6 +52,11 @@ struct FileReferenceAccumulator {
|
||||
}, [](const MTPDdocumentEmpty &data) {
|
||||
});
|
||||
}
|
||||
void push(const MTPWallPaper &data) {
|
||||
data.match([&](const MTPDwallPaper &data) {
|
||||
push(data.vdocument);
|
||||
});
|
||||
}
|
||||
void push(const MTPUserProfilePhoto &data) {
|
||||
data.match([&](const MTPDuserProfilePhoto &data) {
|
||||
push(data.vphoto_small);
|
||||
@ -173,6 +178,12 @@ struct FileReferenceAccumulator {
|
||||
}, [](const MTPDmessages_savedGifsNotModified &data) {
|
||||
});
|
||||
}
|
||||
void push(const MTPaccount_WallPapers &data) {
|
||||
data.match([&](const MTPDaccount_wallPapers &data) {
|
||||
push(data.vwallpapers);
|
||||
}, [](const MTPDaccount_wallPapersNotModified &) {
|
||||
});
|
||||
}
|
||||
|
||||
UpdatedFileReferences result;
|
||||
};
|
||||
@ -237,4 +248,8 @@ UpdatedFileReferences GetFileReferences(const MTPmessages_SavedGifs &data) {
|
||||
return GetFileReferencesHelper(data);
|
||||
}
|
||||
|
||||
UpdatedFileReferences GetFileReferences(const MTPaccount_WallPapers &data) {
|
||||
return GetFileReferencesHelper(data);
|
||||
}
|
||||
|
||||
} // namespace Data
|
||||
|
@ -60,13 +60,20 @@ struct FileOriginSavedGifs {
|
||||
}
|
||||
};
|
||||
|
||||
struct FileOriginWallpapers {
|
||||
inline bool operator<(const FileOriginWallpapers &) const {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct FileOrigin {
|
||||
using Variant = base::optional_variant<
|
||||
FileOriginMessage,
|
||||
FileOriginUserPhoto,
|
||||
FileOriginPeerPhoto,
|
||||
FileOriginStickerSet,
|
||||
FileOriginSavedGifs>;
|
||||
FileOriginSavedGifs,
|
||||
FileOriginWallpapers>;
|
||||
|
||||
FileOrigin() = default;
|
||||
FileOrigin(FileOriginMessage data) : data(data) {
|
||||
@ -79,6 +86,8 @@ struct FileOrigin {
|
||||
}
|
||||
FileOrigin(FileOriginSavedGifs data) : data(data) {
|
||||
}
|
||||
FileOrigin(FileOriginWallpapers data) : data(data) {
|
||||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
return data.has_value();
|
||||
@ -121,5 +130,6 @@ UpdatedFileReferences GetFileReferences(
|
||||
const MTPmessages_FavedStickers &data);
|
||||
UpdatedFileReferences GetFileReferences(const MTPmessages_StickerSet &data);
|
||||
UpdatedFileReferences GetFileReferences(const MTPmessages_SavedGifs &data);
|
||||
UpdatedFileReferences GetFileReferences(const MTPaccount_WallPapers &data);
|
||||
|
||||
} // namespace Data
|
||||
|
@ -1422,9 +1422,12 @@ void MainWidget::setChatBackground(const Data::WallPaper &background) {
|
||||
_background = std::make_unique<SettingBackground>();
|
||||
_background->data = background;
|
||||
if (_background->data.document) {
|
||||
_background->data.document->save(Data::FileOrigin(), QString());
|
||||
_background->data.document->save(
|
||||
Data::FileOriginWallpapers(),
|
||||
QString());
|
||||
} else if (_background->data.thumb) {
|
||||
_background->data.thumb->loadEvenCancelled(Data::FileOrigin());
|
||||
_background->data.thumb->loadEvenCancelled(
|
||||
Data::FileOriginWallpapers());
|
||||
}
|
||||
checkChatBackground();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user