mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
store and sort by m.lowpriority tag
This commit is contained in:
parent
1ee592ea85
commit
6a9cbf7f33
@ -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 New Issue
Block a user