mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Load cloud image without active view only once.
This commit is contained in:
parent
01c2be3f01
commit
d199e16a6e
2 changed files with 10 additions and 1 deletions
|
@ -99,13 +99,19 @@ bool CloudImage::failed() const {
|
|||
return (_file.flags & CloudFile::Flag::Failed);
|
||||
}
|
||||
|
||||
bool CloudImage::loadedOnce() const {
|
||||
return (_file.flags & CloudFile::Flag::Loaded);
|
||||
}
|
||||
|
||||
void CloudImage::load(not_null<Main::Session*> session, FileOrigin origin) {
|
||||
const auto autoLoading = false;
|
||||
const auto finalCheck = [=] {
|
||||
if (const auto active = activeView()) {
|
||||
return !active->image();
|
||||
} else if (_file.flags & CloudFile::Flag::Loaded) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(_file.flags & CloudFile::Flag::Loaded);
|
||||
};
|
||||
const auto done = [=](QImage result) {
|
||||
if (const auto active = activeView()) {
|
||||
|
@ -247,6 +253,7 @@ void LoadCloudFile(
|
|||
if (!file.loader || file.loader->cancelled()) {
|
||||
file.flags |= CloudFile::Flag::Cancelled;
|
||||
} else {
|
||||
file.flags |= CloudFile::Flag::Loaded;
|
||||
done(file);
|
||||
}
|
||||
// NB! file.loader may be in ~FileLoader() already.
|
||||
|
|
|
@ -31,6 +31,7 @@ struct CloudFile final {
|
|||
enum class Flag : uchar {
|
||||
Cancelled = 0x01,
|
||||
Failed = 0x02,
|
||||
Loaded = 0x04,
|
||||
};
|
||||
friend inline constexpr bool is_flag_type(Flag) { return true; };
|
||||
|
||||
|
@ -73,6 +74,7 @@ public:
|
|||
[[nodiscard]] bool empty() const;
|
||||
[[nodiscard]] bool loading() const;
|
||||
[[nodiscard]] bool failed() const;
|
||||
[[nodiscard]] bool loadedOnce() const;
|
||||
void load(not_null<Main::Session*> session, FileOrigin origin);
|
||||
[[nodiscard]] const ImageLocation &location() const;
|
||||
[[nodiscard]] int byteSize() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue