Skip to content

Commit 29db441

Browse files
committed
Export: fix from-date boundary and respect range in topic media loader
Address edge cases on top of the offset_date jump: * SingleMessageAfter: switch the comparison to >= so a split whose newest message has date == singlePeerFrom is not pre-skipped by the count probe. SkipMessageByDate keeps messages with singlePeerFrom <= date, so the pre-iteration filter must match that inclusive lower bound. * requestChatMessages (onlyMyMessages branch): messages.search uses strict > for min_date and strict < for max_date, while the exporter's canonical range is [singlePeerFrom, singlePeerTill). Pass min_date = singlePeerFrom - 1 to keep messages dated exactly singlePeerFrom; max_date stays singlePeerTill. * loadNextTopicMessageFile: skip media download for messages outside the date range, mirroring loadNextMessageFile for the chat path. Without this, topic exports with a date filter still trigger downloads for out-of-range messages. * changelog.txt: add a user-facing entry.
1 parent 16a23f7 commit 29db441

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

Telegram/SourceFiles/export/data/export_data_types.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2607,7 +2607,10 @@ bool SingleMessageAfter(
26072607
const MTPmessages_Messages &data,
26082608
TimeId date) {
26092609
const auto single = SingleMessageDate(data);
2610-
return (single > 0 && single > date);
2610+
// Inclusive lower bound: SkipMessageByDate keeps messages with
2611+
// `singlePeerFrom <= date`, so a split whose newest message has the
2612+
// exact `singlePeerFrom` date must not be pre-skipped here.
2613+
return (single > 0 && single >= date);
26112614
}
26122615

26132616
bool SkipMessageByDate(const Message &message, const Settings &settings) {

Telegram/SourceFiles/export/export_api_wrap.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,8 +1941,13 @@ void ApiWrap::requestChatMessages(
19411941
: (splitsCount + splitIndex);
19421942
// Narrow server-side scan when the user requested a date range, so we
19431943
// don't pull every message in the chat just to skip them client-side.
1944+
// messages.search uses strict comparison for both bounds (date >
1945+
// min_date and date < max_date), while the exporter's canonical range
1946+
// is `[singlePeerFrom, singlePeerTill)` (see SkipMessageByDate). To
1947+
// match it exactly we shift min_date down by 1 and pass singlePeerTill
1948+
// through unchanged.
19441949
const auto minDate = (_settings->singlePeerFrom > 0)
1945-
? _settings->singlePeerFrom
1950+
? (_settings->singlePeerFrom - 1)
19461951
: 0;
19471952
const auto maxDate = (_settings->singlePeerTill > 0)
19481953
? _settings->singlePeerTill
@@ -2603,6 +2608,9 @@ void ApiWrap::loadNextTopicMessageFile() {
26032608
; _topicProcess->fileIndex < list.size()
26042609
; ++_topicProcess->fileIndex) {
26052610
auto &message = list[_topicProcess->fileIndex];
2611+
if (Data::SkipMessageByDate(message, *_settings)) {
2612+
continue;
2613+
}
26062614
if (!messageCustomEmojiReady(message)) {
26072615
return;
26082616
}

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
6.8.3 beta (19.05.26)
22

3+
- Export now jumps to the picked "from date" instead of walking the whole chat.
34
- In-app markdown file viewer.
45
- Native Instant View support.
56
- Native external webapp viewer on Linux.

0 commit comments

Comments
 (0)