Skip to content

Commit

Permalink
Don't suggest export if one is running.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 24, 2018
1 parent 914e043 commit a200771
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
9 changes: 6 additions & 3 deletions Telegram/SourceFiles/data/data_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,20 @@ 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 {
if (left) {
App::CallDelayed(
std::min(left + 5, 3600) * TimeMs(1000),
_session,
[=] { suggestStartExport(); });
} else if (_export) {
Export::View::ClearSuggestStart();
} else {
Export::View::SuggestStart();
}
}

Expand Down
8 changes: 1 addition & 7 deletions Telegram/SourceFiles/export/export_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,17 +613,11 @@ void Controller::fillMessagesState(
int addIndex,
int addCount) const {
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.entityCount = info.list.size() + addCount;
result.entityName = dialog.name;
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
if (!progress.path.isEmpty()) {
const auto last = progress.path.lastIndexOf('/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ void SuggestBox::prepare() {
return;
}
_cleared = true;

auto settings = Local::ReadExportSettings();
settings.availableAt = 0;
Local::WriteExportSettings(settings);
ClearSuggestStart();
};

addButton(langFactory(lng_box_ok), [=] {
Expand Down Expand Up @@ -92,6 +89,12 @@ void SuggestStart() {
Ui::show(Box<SuggestBox>(), LayerOption::KeepOther);
}

void ClearSuggestStart() {
auto settings = Local::ReadExportSettings();
settings.availableAt = 0;
Local::WriteExportSettings(settings);
}

PanelController::PanelController(not_null<ControllerWrap*> process)
: _process(process)
, _settings(std::make_unique<Settings>(Local::ReadExportSettings()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace Export {
namespace View {

void SuggestStart();
void ClearSuggestStart();

class Panel;

Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/settings/settings_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ void fillCodes() {
Messenger::Instance().onSwitchDebugMode();
}));
});
Codes.insert(qsl("viewlogs"), [] {
File::ShowInFolder(cWorkingDir() + "log.txt");
});
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.");
Ui::show(Box<ConfirmBox>(text, [] {
Expand Down

0 comments on commit a200771

Please sign in to comment.