Handle first tag added/last tag removed

This is a special case because untagged rooms should
appear in im.vector.fake.recent and tagged rooms
should not.
This commit is contained in:
lukebarnard 2018-02-06 12:00:06 +00:00
parent b744dbaab7
commit 8d0d0b43ff

View file

@ -101,6 +101,16 @@ class RoomListStore extends Store {
_updateRoomListsOptimistic(updatedRoom, oldTag, newTag, metaData) { _updateRoomListsOptimistic(updatedRoom, oldTag, newTag, metaData) {
const newLists = {}; const newLists = {};
// Adding a tag to an untagged room - need to remove it from recents
if (newTag && Object.keys(updatedRoom.tags).length === 0) {
oldTag = 'im.vector.fake.recent';
}
// Removing a tag from a room with one tag left - need to add it to recents
if (oldTag && Object.keys(updatedRoom.tags).length === 1) {
newTag = 'im.vector.fake.recent';
}
// Remove room from oldTag // Remove room from oldTag
Object.keys(this._state.lists).forEach((tagName) => { Object.keys(this._state.lists).forEach((tagName) => {
if (tagName === oldTag) { if (tagName === oldTag) {