Remove forgotten rooms from the view

This commit is contained in:
miruka 2019-07-07 22:19:17 -04:00
parent 47327c64cf
commit b02fc11903
9 changed files with 26 additions and 20 deletions

View File

@ -1,3 +1,6 @@
- room doesn't change category when accept/reject invite
- forget doesn't delete
- "rejoin" leftbanner button if room is public - "rejoin" leftbanner button if room is public
- daybreak color - daybreak color
- html links color - html links color
@ -14,6 +17,7 @@ sticky avatar at top
ability to cancel message being sent ability to cancel message being sent
nio nio
set typing
fix `RoomForgetResponse.create_error` fix `RoomForgetResponse.create_error`
OLD OLD

View File

@ -60,9 +60,8 @@ class RoomUpdated(Event):
@dataclass @dataclass
class RoomDeleted(Event): class RoomForgotten(Event):
user_id: str = field() user_id: str = field()
category: str = field()
room_id: str = field() room_id: str = field()

View File

@ -188,6 +188,11 @@ class MatrixClient(nio.AsyncClient):
return more_to_load return more_to_load
async def room_forget(self, room_id: str) -> None:
await super().room_forget(room_id)
rooms.RoomForgotten(user_id=self.user_id, room_id=room_id)
# Callbacks for nio responses # Callbacks for nio responses
async def onSyncResponse(self, resp: nio.SyncResponse) -> None: async def onSyncResponse(self, resp: nio.SyncResponse) -> None:

View File

@ -3,8 +3,10 @@ import QtQuick 2.7
HAvatar { HAvatar {
property string roomId: "" property string roomId: ""
// roomInfo ? Avoid error messages when a room is forgotten
readonly property var roomInfo: rooms.getWhere({"roomId": roomId}, 1)[0] readonly property var roomInfo: rooms.getWhere({"roomId": roomId}, 1)[0]
readonly property var dname: roomInfo.displayName readonly property var dname: roomInfo ? roomInfo.displayName : ""
name: dname[0] == "#" && dname.length > 1 ? dname.substring(1) : dname name: dname[0] == "#" && dname.length > 1 ? dname.substring(1) : dname
imageUrl: roomInfo.avatarUrl imageUrl: roomInfo ? roomInfo.avatarUrl : null
} }

View File

@ -25,11 +25,8 @@ Banner {
button.loading = true button.loading = true
py.callClientCoro( py.callClientCoro(
chatPage.userId, "room_forget", [chatPage.roomId], {}, chatPage.userId, "room_forget", [chatPage.roomId], {},
function() { function() { button.loading = false }
button.loading = false
pageStack.clear()
}
) )
}, }
} }
} }

View File

@ -7,6 +7,7 @@ import "RoomSidePane"
HColumnLayout { HColumnLayout {
property var roomInfo: null property var roomInfo: null
onRoomInfoChanged: if (! roomInfo) { pageStack.showPage("Default") }
readonly property string userId: roomInfo.userId readonly property string userId: roomInfo.userId
readonly property string category: roomInfo.category readonly property string category: roomInfo.category

View File

@ -79,9 +79,8 @@ function onRoomUpdated(
} }
function onRoomDeleted(user_id, category, room_id) { function onRoomForgotten(user_id, room_id) {
var roles = {"userId": user_id, "roomId": room_id, "category": category} rooms.popWhere({"userId": user_id, "roomId": room_id})
rooms.popWhere(roles, 1)
} }

View File

@ -1,11 +1,4 @@
import QtQuick 2.7 import QtQuick 2.7
import SortFilterProxyModel 0.2
import "../Base" import "../Base"
HListModel { HListModel {}
sorters: FilterSorter {
ValueFilter { roleName: "name"; value: "Invites" }
ValueFilter { roleName: "name"; value: "Rooms" }
ValueFilter { roleName: "name"; value: "Left" }
}
}

View File

@ -14,6 +14,12 @@ HListView {
roleName: "userId" roleName: "userId"
value: userId value: userId
} }
sorters: FilterSorter {
ValueFilter { roleName: "name"; value: "Invites" }
ValueFilter { roleName: "name"; value: "Rooms" }
ValueFilter { roleName: "name"; value: "Left" }
}
} }
delegate: RoomCategoryDelegate {} delegate: RoomCategoryDelegate {}