Skip to content

Commit

Permalink
Unite Dialogs and LeftChannels in Export.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 20, 2018
1 parent 156c3d2 commit 0a5eac5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
31 changes: 22 additions & 9 deletions Telegram/SourceFiles/export/export_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ class Controller {
ProcessingState &result,
const Data::DialogsInfo &info,
int index,
const DownloadProgress &progress) const;
const DownloadProgress &progress,
int addIndex,
int addCount) const;

int substepsInStep(Step step) const;

Expand Down Expand Up @@ -550,15 +552,16 @@ ProcessingState Controller::stateLeftChannelsList(int processed) const {
result.entityIndex = processed;
result.entityCount = std::max(
processed,
substepsInStep(Step::LeftChannels));
substepsInStep(Step::LeftChannels))
+ substepsInStep(Step::Dialogs);
});
}

ProcessingState Controller::stateDialogsList(int processed) const {
const auto step = Step::DialogsList;
return prepareState(step, [&](ProcessingState &result) {
result.entityIndex = processed;
result.entityCount = std::max(
result.entityIndex = substepsInStep(Step::LeftChannels) + processed;
result.entityCount = substepsInStep(Step::LeftChannels) + std::max(
processed,
substepsInStep(Step::Dialogs));
});
Expand Down Expand Up @@ -594,40 +597,50 @@ ProcessingState Controller::stateLeftChannels(
const DownloadProgress & progress) const {
const auto step = Step::LeftChannels;
return prepareState(step, [&](ProcessingState &result) {
const auto addIndex = _dialogsInfo.list.size();
const auto addCount = addIndex;
fillMessagesState(
result,
_leftChannelsInfo,
_leftChannelIndex,
progress);
progress,
addIndex,
addCount);
});
}

ProcessingState Controller::stateDialogs(
const DownloadProgress &progress) const {
const auto step = Step::Dialogs;
return prepareState(step, [&](ProcessingState &result) {
const auto addIndex = 0;
const auto addCount = _leftChannelsInfo.list.size();
fillMessagesState(
result,
_dialogsInfo,
_dialogIndex,
progress);
progress,
addIndex,
addCount);
});
}

void Controller::fillMessagesState(
ProcessingState &result,
const Data::DialogsInfo &info,
int index,
const DownloadProgress &progress) const {
const DownloadProgress &progress,
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;
result.entityCount = info.list.size();
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);
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/export/export_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct ProcessingState {

QString entityName;
int entityIndex = 0;
int entityCount = 1;
int entityCount = 0;

int itemIndex = 0;
int itemCount = 0;
Expand Down

0 comments on commit 0a5eac5

Please sign in to comment.