Add login page and forget room system
This commit is contained in:
@@ -26,6 +26,8 @@ class Client(QObject):
|
||||
roomJoined = pyqtSignal(str)
|
||||
roomLeft = pyqtSignal([str, dict], [str])
|
||||
|
||||
roomAboutToBeForgotten = pyqtSignal(str)
|
||||
|
||||
roomSyncPrevBatchTokenReceived = pyqtSignal(str, str)
|
||||
roomPastPrevBatchTokenReceived = pyqtSignal(str, str)
|
||||
roomEventReceived = pyqtSignal(str, str, dict)
|
||||
@@ -259,4 +261,5 @@ class Client(QObject):
|
||||
@pyqtSlot(str)
|
||||
@futurize()
|
||||
def forgetRoom(self, room_id: str) -> None:
|
||||
raise NotImplementedError()
|
||||
self.roomAboutToBeForgotten.emit(room_id)
|
||||
return self.net.talk(self.nio.room_forget, room_id=room_id)
|
||||
|
@@ -25,7 +25,7 @@ _CONFIG_LOCK = threading.Lock()
|
||||
class ClientManager(QObject):
|
||||
clientAdded = pyqtSignal(Client)
|
||||
clientDeleted = pyqtSignal(str)
|
||||
_clientsUpdate = pyqtSignal()
|
||||
clientCountChanged = pyqtSignal(int)
|
||||
|
||||
|
||||
def __init__(self, backend: Backend) -> None:
|
||||
@@ -33,19 +33,25 @@ class ClientManager(QObject):
|
||||
self.backend = backend
|
||||
self._clients: Dict[str, Client] = {}
|
||||
|
||||
self.clientAdded.connect(self._clientsUpdate.emit)
|
||||
self.clientDeleted.connect(self._clientsUpdate.emit)
|
||||
func = lambda: self.clientCountChanged.emit(len(self.clients))
|
||||
self.clientAdded.connect(func)
|
||||
self.clientDeleted.connect(func)
|
||||
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{type(self).__name__}(clients={self.clients!r})"
|
||||
|
||||
|
||||
@pyqtProperty("QVariantMap", notify=_clientsUpdate)
|
||||
@pyqtProperty("QVariantMap", notify=clientCountChanged)
|
||||
def clients(self):
|
||||
return self._clients
|
||||
|
||||
|
||||
@pyqtProperty(int, notify=clientCountChanged)
|
||||
def clientCount(self):
|
||||
return len(self.clients)
|
||||
|
||||
|
||||
@pyqtSlot()
|
||||
def configLoad(self) -> None:
|
||||
for user_id, info in self.configAccounts().items():
|
||||
|
@@ -114,6 +114,7 @@ class NetworkManager:
|
||||
nio_func: NioRequestFunc,
|
||||
*args,
|
||||
**kwargs) -> nr.Response:
|
||||
|
||||
with self._lock:
|
||||
retry = RetrySleeper()
|
||||
|
||||
|
@@ -268,3 +268,11 @@ class SignalManager(QObject):
|
||||
self._events_in_transfer += 1
|
||||
|
||||
self._move_room(client.userId, room_id)
|
||||
|
||||
|
||||
def onRoomAboutToBeForgotten(self, client: Client, room_id: str) -> None:
|
||||
with self._lock:
|
||||
rooms = self.backend.models.rooms[client.userId]
|
||||
del rooms[rooms.indexWhere("roomId", room_id)]
|
||||
|
||||
self.backend.models.roomEvents[room_id].clear()
|
||||
|
Reference in New Issue
Block a user