2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Suggest start export when time comes.

This commit is contained in:
John Preston
2018-06-23 00:18:43 +01:00
parent 844d030332
commit 0143fd28af
12 changed files with 123 additions and 11 deletions

View File

@@ -83,6 +83,29 @@ void Session::startExport() {
}, _export->lifetime());
}
void Session::suggestStartExport(TimeId availableAt) {
_exportAvailableAt = availableAt;
suggestStartExport();
}
void Session::suggestStartExport() {
if (_exportAvailableAt <= 0) {
return;
}
const auto now = unixtime();
const auto left = (_exportAvailableAt <= now)
? 0
: (_exportAvailableAt - now);
if (!left) {
Export::View::SuggestStart();
} else {
App::CallDelayed(
std::min(left + 5, 3600) * TimeMs(1000),
_session,
[=] { suggestStartExport(); });
}
}
rpl::producer<Export::View::PanelController*> Session::currentExportView(
) const {
return _exportViewChanges.events_starting_with(_exportPanel.get());

View File

@@ -52,6 +52,7 @@ public:
}
void startExport();
void suggestStartExport(TimeId availableAt);
rpl::producer<Export::View::PanelController*> currentExportView() const;
bool exportInProgress() const;
void stopExportWithConfirmation(FnMut<void()> callback);
@@ -408,6 +409,8 @@ public:
}
private:
void suggestStartExport();
void setupContactViewsViewer();
void setupChannelLeavingViewer();
void photoApplyFields(
@@ -505,6 +508,7 @@ private:
std::unique_ptr<Export::ControllerWrap> _export;
std::unique_ptr<Export::View::PanelController> _exportPanel;
rpl::event_stream<Export::View::PanelController*> _exportViewChanges;
TimeId _exportAvailableAt = 0;
base::Variable<bool> _contactsLoaded = { false };
base::Variable<bool> _allChatsLoaded = { false };