mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Merge pull request #75 from vector-im/bwindels/sortbyroomtags
store and sort by m.lowpriority tag
This commit is contained in:
commit
deae644158
@ -73,6 +73,13 @@ export class RoomTileViewModel extends ViewModel {
|
||||
return result;
|
||||
}
|
||||
log(`comparing ${myRoom.name || theirRoom.id} and ${theirRoom.name || theirRoom.id} ...`);
|
||||
log("comparing isLowPriority...");
|
||||
if (myRoom.isLowPriority !== theirRoom.isLowPriority) {
|
||||
if (myRoom.isLowPriority) {
|
||||
return logResult(1);
|
||||
}
|
||||
return logResult(-1);
|
||||
}
|
||||
log("comparing isUnread...");
|
||||
if (isSortedAsUnread(this) !== isSortedAsUnread(other)) {
|
||||
if (isSortedAsUnread(this)) {
|
||||
|
@ -251,6 +251,11 @@ export class Room extends EventEmitter {
|
||||
return this._summary.highlightCount;
|
||||
}
|
||||
|
||||
get isLowPriority() {
|
||||
const tags = this._summary.tags;
|
||||
return !!(tags && tags['m.lowpriority']);
|
||||
}
|
||||
|
||||
async _getLastEventId() {
|
||||
const lastKey = this._syncWriter.lastMessageKey;
|
||||
if (lastKey) {
|
||||
|
@ -22,6 +22,9 @@ function applySyncResponse(data, roomResponse, membership, isInitialSync, isTime
|
||||
data = data.cloneIfNeeded();
|
||||
data.membership = membership;
|
||||
}
|
||||
if (roomResponse.account_data) {
|
||||
data = roomResponse.account_data.events.reduce(processRoomAccountData, data);
|
||||
}
|
||||
// state comes before timeline
|
||||
if (roomResponse.state) {
|
||||
data = roomResponse.state.events.reduce(processStateEvent, data);
|
||||
@ -51,6 +54,18 @@ function applySyncResponse(data, roomResponse, membership, isInitialSync, isTime
|
||||
return data;
|
||||
}
|
||||
|
||||
function processRoomAccountData(data, event) {
|
||||
if (event?.type === "m.tag") {
|
||||
let tags = event?.content?.tags;
|
||||
if (!tags || Array.isArray(tags) || typeof tags !== "object") {
|
||||
tags = null;
|
||||
}
|
||||
data = data.cloneIfNeeded();
|
||||
data.tags = tags;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function processStateEvent(data, event) {
|
||||
if (event.type === "m.room.encryption") {
|
||||
if (!data.isEncrypted) {
|
||||
@ -133,6 +148,7 @@ class SummaryData {
|
||||
this.avatarUrl = copy ? copy.avatarUrl : null;
|
||||
this.notificationCount = copy ? copy.notificationCount : 0;
|
||||
this.highlightCount = copy ? copy.highlightCount : 0;
|
||||
this.tags = copy ? copy.tags : null;
|
||||
this.cloned = copy ? true : false;
|
||||
}
|
||||
|
||||
@ -218,6 +234,10 @@ export class RoomSummary {
|
||||
return this._data.lastPaginationToken;
|
||||
}
|
||||
|
||||
get tags() {
|
||||
return this._data.tags;
|
||||
}
|
||||
|
||||
writeClearUnread(txn) {
|
||||
const data = new SummaryData(this._data);
|
||||
data.isUnread = false;
|
||||
|
Loading…
Reference in New Issue
Block a user