Fix export messages pagination.

Also fix reply highlight.
Also fix channel service messages.
Also improve single chat export progress display.
This commit is contained in:
John Preston 2018-07-25 10:38:36 +03:00
parent f852813734
commit 95eab45108
3 changed files with 29 additions and 12 deletions

View File

@ -275,7 +275,7 @@ div.selected {
padding: 10px; padding: 10px;
} }
.default.joined { .default.joined {
padding-top: 0; margin-top: -10px;
} }
.default .from_name { .default .from_name {
color: #3892db; color: #3892db;

View File

@ -958,6 +958,9 @@ auto HtmlWriter::Wrap::pushMessage(
return wrapMessageLink(message.replyToMsgId, text); return wrapMessageLink(message.replyToMsgId, text);
}; };
using DialogType = Data::DialogInfo::Type;
const auto isChannel = (dialog.type == DialogType::PrivateChannel)
|| (dialog.type == DialogType::PublicChannel);
const auto serviceFrom = peers.wrapUserName(message.fromId); const auto serviceFrom = peers.wrapUserName(message.fromId);
const auto serviceText = message.action.content.match( const auto serviceText = message.action.content.match(
[&](const ActionChatCreate &data) { [&](const ActionChatCreate &data) {
@ -967,14 +970,20 @@ auto HtmlWriter::Wrap::pushMessage(
? QByteArray() ? QByteArray()
: " with members " + peers.wrapUserNames(data.userIds)); : " with members " + peers.wrapUserNames(data.userIds));
}, [&](const ActionChatEditTitle &data) { }, [&](const ActionChatEditTitle &data) {
return serviceFrom return isChannel
+ " changed group title to «" + data.title + "»"; ? ("Channel title changed to «" + data.title + "»")
: (serviceFrom
+ " changed group title to «"
+ data.title
+ "»");
}, [&](const ActionChatEditPhoto &data) { }, [&](const ActionChatEditPhoto &data) {
return serviceFrom return isChannel
+ " changed group photo"; ? QByteArray("Channel photo changed")
: (serviceFrom + " changed group photo");
}, [&](const ActionChatDeletePhoto &data) { }, [&](const ActionChatDeletePhoto &data) {
return serviceFrom return isChannel
+ " deleted group photo"; ? QByteArray("Channel photo removed")
: (serviceFrom + " removed group photo");
}, [&](const ActionChatAddUser &data) { }, [&](const ActionChatAddUser &data) {
return serviceFrom return serviceFrom
+ " invited " + " invited "
@ -2263,7 +2272,9 @@ Result HtmlWriter::writeDialogSlice(const Data::MessagesSlice &data) {
const auto messageLinkWrapper = [&](int messageId, QByteArray text) { const auto messageLinkWrapper = [&](int messageId, QByteArray text) {
return wrapMessageLink(messageId, text); return wrapMessageLink(messageId, text);
}; };
auto oldIndex = (_messagesCount / kMessagesInFile); auto oldIndex = (_messagesCount > 0)
? ((_messagesCount - 1) / kMessagesInFile)
: 0;
auto previous = _lastMessageInfo.get(); auto previous = _lastMessageInfo.get();
auto saved = base::optional<MessageInfo>(); auto saved = base::optional<MessageInfo>();
auto block = QByteArray(); auto block = QByteArray();

View File

@ -41,10 +41,16 @@ Content ContentFromState(const ProcessingState &state) {
const auto done = state.substepsPassed; const auto done = state.substepsPassed;
const auto add = state.substepsNow; const auto add = state.substepsNow;
const auto doneProgress = done / float64(substepsTotal); const auto doneProgress = done / float64(substepsTotal);
const auto addProgress = (state.entityCount > 0) const auto addPart = [&](int index, int count) {
? ((float64(add) * state.entityIndex) return (count > 0)
/ (float64(substepsTotal) * state.entityCount)) ? ((float64(add) * index)
: 0.; / (float64(substepsTotal) * count))
: 0.;
};
const auto addProgress = (state.entityCount == 1
&& !state.entityIndex)
? addPart(state.itemIndex, state.itemCount)
: addPart(state.entityIndex, state.entityCount);
push("main", label, info, doneProgress + addProgress); push("main", label, info, doneProgress + addProgress);
}; };
const auto pushBytes = [&](const QString &id, const QString &label) { const auto pushBytes = [&](const QString &id, const QString &label) {