Don't suggest export if one is running.

This commit is contained in:
John Preston 2018-06-23 22:21:32 +01:00
parent 914e043abe
commit a200771868
5 changed files with 18 additions and 14 deletions

View File

@ -92,17 +92,20 @@ void Session::suggestStartExport() {
if (_exportAvailableAt <= 0) { if (_exportAvailableAt <= 0) {
return; return;
} }
const auto now = unixtime(); const auto now = unixtime();
const auto left = (_exportAvailableAt <= now) const auto left = (_exportAvailableAt <= now)
? 0 ? 0
: (_exportAvailableAt - now); : (_exportAvailableAt - now);
if (!left) { if (left) {
Export::View::SuggestStart();
} else {
App::CallDelayed( App::CallDelayed(
std::min(left + 5, 3600) * TimeMs(1000), std::min(left + 5, 3600) * TimeMs(1000),
_session, _session,
[=] { suggestStartExport(); }); [=] { suggestStartExport(); });
} else if (_export) {
Export::View::ClearSuggestStart();
} else {
Export::View::SuggestStart();
} }
} }

View File

@ -613,17 +613,11 @@ void Controller::fillMessagesState(
int addIndex, int addIndex,
int addCount) const { int addCount) const {
const auto &dialog = info.list[index]; const auto &dialog = info.list[index];
auto count = 0;
for (const auto &dialog : info.list) {
if (dialog.name.isEmpty()) {
++count;
}
}
result.entityIndex = index + addIndex; result.entityIndex = index + addIndex;
result.entityCount = info.list.size() + addCount; result.entityCount = info.list.size() + addCount;
result.entityName = dialog.name; result.entityName = dialog.name;
result.itemIndex = _messagesWritten + progress.itemIndex; result.itemIndex = _messagesWritten + progress.itemIndex;
result.itemCount = std::max(_messagesCount, result.entityIndex); result.itemCount = std::max(_messagesCount, result.itemIndex);
result.bytesType = ProcessingState::FileType::File; // TODO result.bytesType = ProcessingState::FileType::File; // TODO
if (!progress.path.isEmpty()) { if (!progress.path.isEmpty()) {
const auto last = progress.path.lastIndexOf('/'); const auto last = progress.path.lastIndexOf('/');

View File

@ -51,10 +51,7 @@ void SuggestBox::prepare() {
return; return;
} }
_cleared = true; _cleared = true;
ClearSuggestStart();
auto settings = Local::ReadExportSettings();
settings.availableAt = 0;
Local::WriteExportSettings(settings);
}; };
addButton(langFactory(lng_box_ok), [=] { addButton(langFactory(lng_box_ok), [=] {
@ -92,6 +89,12 @@ void SuggestStart() {
Ui::show(Box<SuggestBox>(), LayerOption::KeepOther); Ui::show(Box<SuggestBox>(), LayerOption::KeepOther);
} }
void ClearSuggestStart() {
auto settings = Local::ReadExportSettings();
settings.availableAt = 0;
Local::WriteExportSettings(settings);
}
PanelController::PanelController(not_null<ControllerWrap*> process) PanelController::PanelController(not_null<ControllerWrap*> process)
: _process(process) : _process(process)
, _settings(std::make_unique<Settings>(Local::ReadExportSettings())) , _settings(std::make_unique<Settings>(Local::ReadExportSettings()))

View File

@ -22,6 +22,7 @@ namespace Export {
namespace View { namespace View {
void SuggestStart(); void SuggestStart();
void ClearSuggestStart();
class Panel; class Panel;

View File

@ -50,6 +50,9 @@ void fillCodes() {
Messenger::Instance().onSwitchDebugMode(); Messenger::Instance().onSwitchDebugMode();
})); }));
}); });
Codes.insert(qsl("viewlogs"), [] {
File::ShowInFolder(cWorkingDir() + "log.txt");
});
Codes.insert(qsl("testmode"), [] { Codes.insert(qsl("testmode"), [] {
auto text = cTestMode() ? qsl("Do you want to disable TEST mode?") : qsl("Do you want to enable TEST mode?\n\nYou will be switched to test cloud."); auto text = cTestMode() ? qsl("Do you want to disable TEST mode?") : qsl("Do you want to enable TEST mode?\n\nYou will be switched to test cloud.");
Ui::show(Box<ConfirmBox>(text, [] { Ui::show(Box<ConfirmBox>(text, [] {