mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
add method to clear unread state
This commit is contained in:
parent
4419b3366e
commit
739d74bf9c
@ -184,6 +184,23 @@ export class Room extends EventEmitter {
|
|||||||
return this._summary.avatarUrl;
|
return this._summary.avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async clearUnread() {
|
||||||
|
const txn = await this._storage.readWriteTxn([
|
||||||
|
this._storage.storeNames.roomSummary,
|
||||||
|
]);
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = this._summary.writeClearUnread(txn);
|
||||||
|
} catch (err) {
|
||||||
|
txn.abort();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
await txn.complete();
|
||||||
|
this._summary.applyChanges(data);
|
||||||
|
this.emit("change");
|
||||||
|
this._emitCollectionChange(this);
|
||||||
|
}
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
async openTimeline() {
|
async openTimeline() {
|
||||||
if (this._timeline) {
|
if (this._timeline) {
|
||||||
|
@ -191,6 +191,15 @@ export class RoomSummary {
|
|||||||
return this._data.lastPaginationToken;
|
return this._data.lastPaginationToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writeClearUnread(txn) {
|
||||||
|
const data = new SummaryData(this._data);
|
||||||
|
data.isUnread = false;
|
||||||
|
data.notificationCount = 0;
|
||||||
|
data.highlightCount = 0;
|
||||||
|
txn.roomSummary.set(data.serialize());
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
writeHasFetchedMembers(value, txn) {
|
writeHasFetchedMembers(value, txn) {
|
||||||
const data = new SummaryData(this._data);
|
const data = new SummaryData(this._data);
|
||||||
data.hasFetchedMembers = value;
|
data.hasFetchedMembers = value;
|
||||||
|
Loading…
Reference in New Issue
Block a user