mirror of https://github.com/procxx/kepka.git
Show reload toast inside Support::Templates.
This commit is contained in:
parent
123523ef62
commit
d6b4448d3c
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "support/support_templates.h"
|
#include "support/support_templates.h"
|
||||||
|
|
||||||
|
#include "ui/toast/toast.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
|
|
||||||
|
@ -447,10 +448,21 @@ struct Templates::Updates {
|
||||||
};
|
};
|
||||||
|
|
||||||
Templates::Templates(not_null<AuthSession*> session) : _session(session) {
|
Templates::Templates(not_null<AuthSession*> session) : _session(session) {
|
||||||
reload();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Templates::reload() {
|
void Templates::reload() {
|
||||||
|
_reloadToastSubscription = errors(
|
||||||
|
) | rpl::start_with_next([=](QStringList errors) {
|
||||||
|
Ui::Toast::Show(errors.isEmpty()
|
||||||
|
? "Templates reloaded!"
|
||||||
|
: ("Errors:\n\n" + errors.join("\n\n")));
|
||||||
|
});
|
||||||
|
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Templates::load() {
|
||||||
if (_reloadAfterRead) {
|
if (_reloadAfterRead) {
|
||||||
return;
|
return;
|
||||||
} else if (_reading.alive() || _updates) {
|
} else if (_reading.alive() || _updates) {
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
private:
|
private:
|
||||||
struct Updates;
|
struct Updates;
|
||||||
|
|
||||||
|
void load();
|
||||||
void update();
|
void update();
|
||||||
void ensureUpdatesCreated();
|
void ensureUpdatesCreated();
|
||||||
void updateRequestFinished(QNetworkReply *reply);
|
void updateRequestFinished(QNetworkReply *reply);
|
||||||
|
@ -81,6 +82,7 @@ private:
|
||||||
rpl::event_stream<QStringList> _errors;
|
rpl::event_stream<QStringList> _errors;
|
||||||
base::binary_guard _reading;
|
base::binary_guard _reading;
|
||||||
bool _reloadAfterRead = false;
|
bool _reloadAfterRead = false;
|
||||||
|
rpl::lifetime _reloadToastSubscription;
|
||||||
|
|
||||||
int _maxKeyLength = 0;
|
int _maxKeyLength = 0;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/menu.h"
|
#include "ui/widgets/menu.h"
|
||||||
#include "ui/toast/toast.h"
|
|
||||||
#include "ui/special_buttons.h"
|
#include "ui/special_buttons.h"
|
||||||
#include "ui/empty_userpic.h"
|
#include "ui/empty_userpic.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -212,14 +211,7 @@ void MainMenu::refreshMenu() {
|
||||||
(*fix)->setCheckable(true);
|
(*fix)->setCheckable(true);
|
||||||
(*fix)->setChecked(Auth().settings().supportFixChatsOrder());
|
(*fix)->setChecked(Auth().settings().supportFixChatsOrder());
|
||||||
|
|
||||||
const auto subscription = Ui::AttachAsChild(_menu, rpl::lifetime());
|
|
||||||
_menu->addAction(qsl("Reload templates"), [=] {
|
_menu->addAction(qsl("Reload templates"), [=] {
|
||||||
*subscription = Auth().supportTemplates().errors(
|
|
||||||
) | rpl::start_with_next([=](QStringList errors) {
|
|
||||||
Ui::Toast::Show(errors.isEmpty()
|
|
||||||
? "Templates reloaded!"
|
|
||||||
: ("Errors:\n\n" + errors.join("\n\n")));
|
|
||||||
});
|
|
||||||
Auth().supportTemplates().reload();
|
Auth().supportTemplates().reload();
|
||||||
}, &st::mainMenuReload, &st::mainMenuReloadOver);
|
}, &st::mainMenuReload, &st::mainMenuReloadOver);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue