Merge branch 'master' into bwindels/e2ee

This commit is contained in:
Bruno Windels 2020-08-28 12:11:33 +02:00
commit d7d1d8c45a
4 changed files with 33 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "hydrogen-web", "name": "hydrogen-web",
"version": "0.0.33", "version": "0.0.34",
"description": "A javascript matrix client prototype, trying to minize RAM usage by offloading as much as possible to IndexedDB", "description": "A javascript matrix client prototype, trying to minize RAM usage by offloading as much as possible to IndexedDB",
"main": "index.js", "main": "index.js",
"directories": { "directories": {

View file

@ -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)) {

View file

@ -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) {

View file

@ -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;