forked from mystiq/hydrogen-web
Merge pull request #75 from vector-im/bwindels/sortbyroomtags
store and sort by m.lowpriority tag
This commit is contained in:
commit
deae644158
3 changed files with 32 additions and 0 deletions
|
@ -73,6 +73,13 @@ export class RoomTileViewModel extends ViewModel {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
log(`comparing ${myRoom.name || theirRoom.id} and ${theirRoom.name || theirRoom.id} ...`);
|
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...");
|
log("comparing isUnread...");
|
||||||
if (isSortedAsUnread(this) !== isSortedAsUnread(other)) {
|
if (isSortedAsUnread(this) !== isSortedAsUnread(other)) {
|
||||||
if (isSortedAsUnread(this)) {
|
if (isSortedAsUnread(this)) {
|
||||||
|
|
|
@ -251,6 +251,11 @@ export class Room extends EventEmitter {
|
||||||
return this._summary.highlightCount;
|
return this._summary.highlightCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isLowPriority() {
|
||||||
|
const tags = this._summary.tags;
|
||||||
|
return !!(tags && tags['m.lowpriority']);
|
||||||
|
}
|
||||||
|
|
||||||
async _getLastEventId() {
|
async _getLastEventId() {
|
||||||
const lastKey = this._syncWriter.lastMessageKey;
|
const lastKey = this._syncWriter.lastMessageKey;
|
||||||
if (lastKey) {
|
if (lastKey) {
|
||||||
|
|
|
@ -22,6 +22,9 @@ function applySyncResponse(data, roomResponse, membership, isInitialSync, isTime
|
||||||
data = data.cloneIfNeeded();
|
data = data.cloneIfNeeded();
|
||||||
data.membership = membership;
|
data.membership = membership;
|
||||||
}
|
}
|
||||||
|
if (roomResponse.account_data) {
|
||||||
|
data = roomResponse.account_data.events.reduce(processRoomAccountData, data);
|
||||||
|
}
|
||||||
// state comes before timeline
|
// state comes before timeline
|
||||||
if (roomResponse.state) {
|
if (roomResponse.state) {
|
||||||
data = roomResponse.state.events.reduce(processStateEvent, data);
|
data = roomResponse.state.events.reduce(processStateEvent, data);
|
||||||
|
@ -51,6 +54,18 @@ function applySyncResponse(data, roomResponse, membership, isInitialSync, isTime
|
||||||
return data;
|
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) {
|
function processStateEvent(data, event) {
|
||||||
if (event.type === "m.room.encryption") {
|
if (event.type === "m.room.encryption") {
|
||||||
if (!data.isEncrypted) {
|
if (!data.isEncrypted) {
|
||||||
|
@ -133,6 +148,7 @@ class SummaryData {
|
||||||
this.avatarUrl = copy ? copy.avatarUrl : null;
|
this.avatarUrl = copy ? copy.avatarUrl : null;
|
||||||
this.notificationCount = copy ? copy.notificationCount : 0;
|
this.notificationCount = copy ? copy.notificationCount : 0;
|
||||||
this.highlightCount = copy ? copy.highlightCount : 0;
|
this.highlightCount = copy ? copy.highlightCount : 0;
|
||||||
|
this.tags = copy ? copy.tags : null;
|
||||||
this.cloned = copy ? true : false;
|
this.cloned = copy ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,6 +234,10 @@ export class RoomSummary {
|
||||||
return this._data.lastPaginationToken;
|
return this._data.lastPaginationToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get tags() {
|
||||||
|
return this._data.tags;
|
||||||
|
}
|
||||||
|
|
||||||
writeClearUnread(txn) {
|
writeClearUnread(txn) {
|
||||||
const data = new SummaryData(this._data);
|
const data = new SummaryData(this._data);
|
||||||
data.isUnread = false;
|
data.isUnread = false;
|
||||||
|
|
Loading…
Reference in a new issue