mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-10 20:17:32 +01:00
send receipt to server when clearing unread state so notif count clears
This commit is contained in:
parent
9b16119e7b
commit
2bfbb41ee7
@ -136,6 +136,11 @@ export class HomeServerApi {
|
|||||||
return this._put(`/rooms/${encodeURIComponent(roomId)}/send/${encodeURIComponent(eventType)}/${encodeURIComponent(txnId)}`, {}, content, options);
|
return this._put(`/rooms/${encodeURIComponent(roomId)}/send/${encodeURIComponent(eventType)}/${encodeURIComponent(txnId)}`, {}, content, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
receipt(roomId, receiptType, eventId, options = null) {
|
||||||
|
return this._post(`/rooms/${encodeURIComponent(roomId)}/receipt/${encodeURIComponent(receiptType)}/${encodeURIComponent(eventId)}`,
|
||||||
|
{}, {}, options);
|
||||||
|
}
|
||||||
|
|
||||||
passwordLogin(username, password, options = null) {
|
passwordLogin(username, password, options = null) {
|
||||||
return this._post("/login", null, {
|
return this._post("/login", null, {
|
||||||
"type": "m.login.password",
|
"type": "m.login.password",
|
||||||
|
@ -201,8 +201,23 @@ export class Room extends EventEmitter {
|
|||||||
return this._summary.notificationCount;
|
return this._summary.notificationCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _getLastEventId() {
|
||||||
|
const lastKey = this._syncWriter.lastMessageKey;
|
||||||
|
if (lastKey) {
|
||||||
|
const txn = await this._storage.readTxn([
|
||||||
|
this._storage.storeNames.timelineEvents,
|
||||||
|
]);
|
||||||
|
const eventEntry = await txn.timelineEvents.get(this._roomId, lastKey);
|
||||||
|
return eventEntry?.event?.event_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async clearUnread() {
|
async clearUnread() {
|
||||||
if (this.isUnread) {
|
if (this.isUnread || this.notificationCount) {
|
||||||
|
const lastEventId = await this._getLastEventId();
|
||||||
|
if (lastEventId) {
|
||||||
|
await this._hsApi.receipt(this._roomId, "m.read", lastEventId);
|
||||||
|
}
|
||||||
const txn = await this._storage.readWriteTxn([
|
const txn = await this._storage.readWriteTxn([
|
||||||
this._storage.storeNames.roomSummary,
|
this._storage.storeNames.roomSummary,
|
||||||
]);
|
]);
|
||||||
|
@ -209,6 +209,10 @@ export class SyncWriter {
|
|||||||
afterSync(newLiveKey) {
|
afterSync(newLiveKey) {
|
||||||
this._lastLiveKey = newLiveKey;
|
this._lastLiveKey = newLiveKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get lastMessageKey() {
|
||||||
|
return this._lastLiveKey;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//import MemoryStorage from "../storage/memory/MemoryStorage.js";
|
//import MemoryStorage from "../storage/memory/MemoryStorage.js";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user