Fix room forget and buttons bugs

This commit is contained in:
miruka 2019-04-26 16:52:26 -04:00
parent 5988eccdbb
commit c7dd602687
6 changed files with 33 additions and 17 deletions

View File

@ -93,8 +93,6 @@ class Backend(QObject):
room_id, self.past_tokens[room_id], limit room_id, self.past_tokens[room_id], limit
) )
break break
else:
raise ValueError(f"Room not found in any client: {room_id}")
@pyqtSlot() @pyqtSlot()

View File

@ -23,6 +23,11 @@ class ListModelMap(QObject):
return self.dict[key] return self.dict[key]
@pyqtSlot(str, result=bool)
def has(self, key) -> bool:
return key in self.dict
def __getitem__(self, key) -> ListModel: def __getitem__(self, key) -> ListModel:
return self.dict[key] return self.dict[key]

View File

@ -194,6 +194,10 @@ class SignalManager(QObject):
.fromMSecsSinceEpoch(edict["server_timestamp"]) .fromMSecsSinceEpoch(edict["server_timestamp"])
new_event = RoomEvent(type=etype, dateTime=date_time, dict=edict) new_event = RoomEvent(type=etype, dateTime=date_time, dict=edict)
if etype == "RoomCreateEvent":
print(room_id, "ff")
self.backend.fully_loaded_rooms.add(room_id)
if self._events_in_transfer: if self._events_in_transfer:
local_echoes_met: int = 0 local_echoes_met: int = 0
update_at: Optional[int] = None update_at: Optional[int] = None

View File

@ -60,6 +60,7 @@ Button {
} }
MouseArea { MouseArea {
z: 101
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
propagateComposedEvents: true propagateComposedEvents: true

View File

@ -81,26 +81,33 @@ Rectangle {
iconName: modelData.iconName iconName: modelData.iconName
display: bannerButtons.displayMode display: bannerButtons.displayMode
onClicked: { MouseArea {
if (alreadyClicked) { return } anchors.fill: parent
propagateComposedEvents: true
onClicked: {
if (alreadyClicked) { return }
iconName = "hourglass" iconName = "hourglass"
alreadyClicked = true alreadyClicked = true
// modelData might become undefined after Backend call // modelData might be undefined after Backend call
var signalId = modelData.signalId var signalId = modelData.signalId
var iconName_ = modelData.iconName var isForget =
modelData.clientFunction === "forgetRoom"
var future = var future =
Backend.clientManager.clients[chatPage.userId]. Backend.clientManager.clients[chatPage.userId].
call(modelData.clientFunction, call(modelData.clientFunction,
modelData.clientArgs) modelData.clientArgs)
future.onGotResult.connect(function() { if (! isForget) {
iconName = iconName_ future.onGotResult.connect(function() {
}) iconName = modelData.iconName
})
}
if (signalId) { buttonClicked(signalId) } if (signalId) { buttonClicked(signalId) }
}
} }
Layout.maximumWidth: bannerButtons.compact ? height : -1 Layout.maximumWidth: bannerButtons.compact ? height : -1

View File

@ -111,6 +111,7 @@ Image {
Base.HButton { Base.HButton {
text: qsTr("Login") text: qsTr("Login")
Layout.fillWidth: true Layout.fillWidth: true
} }
Base.HButton { Base.HButton {
text: qsTr("Forgot?") text: qsTr("Forgot?")