diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2020-08-09 23:36:47 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2020-08-09 23:36:47 +0200 |
commit | 14a0aac74873c27c0454d206848f27b4eec123ae (patch) | |
tree | b379bb81158eb8417d8da9b75b1835c7ec07e84c /src/timeline | |
parent | Try to fix variable timestamp width (diff) | |
download | nheko-14a0aac74873c27c0454d206848f27b4eec123ae.tar.xz |
Add /clear-timeline command
Diffstat (limited to 'src/timeline')
-rw-r--r-- | src/timeline/EventStore.cpp | 20 | ||||
-rw-r--r-- | src/timeline/EventStore.h | 1 | ||||
-rw-r--r-- | src/timeline/TimelineModel.h | 1 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.h | 6 |
4 files changed, 28 insertions, 0 deletions
diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index a983fe01..fca1d31d 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -176,6 +176,26 @@ EventStore::addPending(mtx::events::collections::TimelineEvents event) } void +EventStore::clearTimeline() +{ + emit beginResetModel(); + + cache::client()->clearTimeline(room_id_); + auto range = cache::client()->getTimelineRange(room_id_); + if (range) { + nhlog::db()->info("Range {} {}", range->last, range->first); + this->last = range->last; + this->first = range->first; + } else { + this->first = std::numeric_limits<uint64_t>::max(); + this->last = std::numeric_limits<uint64_t>::max(); + } + nhlog::ui()->info("Range {} {}", this->last, this->first); + + emit endResetModel(); +} + +void EventStore::handleSync(const mtx::responses::Timeline &events) { if (this->thread() != QThread::currentThread()) diff --git a/src/timeline/EventStore.h b/src/timeline/EventStore.h index b5c17d10..d4353a18 100644 --- a/src/timeline/EventStore.h +++ b/src/timeline/EventStore.h @@ -101,6 +101,7 @@ signals: public slots: void addPending(mtx::events::collections::TimelineEvents event); + void clearTimeline(); private: mtx::events::collections::TimelineEvents *decryptEvent( diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index f8a84f17..0bcf42b7 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -242,6 +242,7 @@ public slots: } } void setDecryptDescription(bool decrypt) { decryptDescription = decrypt; } + void clearTimeline() { events.clearTimeline(); } private slots: void addPendingMessage(mtx::events::collections::TimelineEvents event); diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 63106916..20dbc3bb 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -92,6 +92,12 @@ public slots: uint64_t dsize); void updateEncryptedDescriptions(); + void clearCurrentRoomTimeline() + { + if (timeline_) + timeline_->clearTimeline(); + } + private: #ifdef USE_QUICK_VIEW QQuickView *view; |