mirror of
https://github.com/kc1awv/rrc-web.git
synced 2026-08-18 09:48:50 -04:00
handle nick changes and fix pre-population of connect modal
This commit is contained in:
parent
9ad99c04f3
commit
56e7f60345
6 changed files with 39 additions and 5 deletions
|
|
@ -634,6 +634,12 @@ class BackendService:
|
|||
"nickname": self.client.nickname if self.client else None,
|
||||
"identity_hash": self.identity.hash.hex() if self.identity else None,
|
||||
"active_room": self.active_room,
|
||||
"config": {
|
||||
"dest_name": self.config.get("dest_name", ""),
|
||||
"hub_hash": self.config.get("hub_hash", ""),
|
||||
"nickname": self.config.get("nickname", ""),
|
||||
"identity_path": self.config.get("identity_path", ""),
|
||||
},
|
||||
"rooms": {
|
||||
name: {
|
||||
"messages": room_data["messages"][-STATE_MESSAGES_TO_RETURN:],
|
||||
|
|
|
|||
|
|
@ -503,7 +503,7 @@ class Client:
|
|||
raise ValueError("Room name cannot be empty. Specify the room to send the message to.")
|
||||
if not text.strip():
|
||||
raise ValueError("Message text cannot be empty. Enter a message to send.")
|
||||
env = make_envelope(T_MSG, src=self.identity.hash, room=r, body=text)
|
||||
env = make_envelope(T_MSG, src=self.identity.hash, room=r, body=text, nick=self.nickname)
|
||||
self._send(env)
|
||||
mid = env.get(K_ID)
|
||||
if not isinstance(mid, (bytes, bytearray)):
|
||||
|
|
@ -530,7 +530,7 @@ class Client:
|
|||
raise ValueError("Room name cannot be empty. Specify the room for the notice.")
|
||||
if not text.strip():
|
||||
raise ValueError("Notice text cannot be empty. Enter notice text to send.")
|
||||
self._send(make_envelope(T_NOTICE, src=self.identity.hash, room=r, body=text))
|
||||
self._send(make_envelope(T_NOTICE, src=self.identity.hash, room=r, body=text, nick=self.nickname))
|
||||
|
||||
def ping(self) -> None:
|
||||
"""Send a PING to the server."""
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ ALLOWED_MESSAGE_TYPES = {
|
|||
"send_message",
|
||||
"send_command",
|
||||
"set_active_room",
|
||||
"set_nickname",
|
||||
"get_state",
|
||||
"get_discovered_hubs",
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -11,6 +11,14 @@
|
|||
let identityPath = $state($connectionSettings.identityPath);
|
||||
let showAdvanced = $state(false);
|
||||
|
||||
// React to changes in connectionSettings store
|
||||
$effect(() => {
|
||||
hubHash = $connectionSettings.hubHash || hubHash;
|
||||
destName = $connectionSettings.destName || destName;
|
||||
nick = $connectionSettings.nickname || nick;
|
||||
identityPath = $connectionSettings.identityPath || identityPath;
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
// Request discovered hubs when dialog opens
|
||||
requestDiscoveredHubs();
|
||||
|
|
|
|||
|
|
@ -123,6 +123,9 @@ function handleMessage(data) {
|
|||
case 'discovered_hubs':
|
||||
handleDiscoveredHubs(data);
|
||||
break;
|
||||
case 'nickname_set':
|
||||
handleNicknameSet(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,6 +293,16 @@ function updateState(data) {
|
|||
identityHash.set(data.identity_hash);
|
||||
}
|
||||
|
||||
if (data.config) {
|
||||
connectionSettings.update(settings => ({
|
||||
...settings,
|
||||
hubHash: data.config.hub_hash || settings.hubHash,
|
||||
destName: data.config.dest_name || settings.destName,
|
||||
nickname: data.config.nickname || settings.nickname,
|
||||
identityPath: data.config.identity_path || settings.identityPath
|
||||
}));
|
||||
}
|
||||
|
||||
if (data.rooms && Object.keys(data.rooms).length > 0) {
|
||||
rooms.update(r => {
|
||||
const newRooms = new Map();
|
||||
|
|
@ -351,6 +364,12 @@ function handleDiscoveredHubs(data) {
|
|||
discoveredHubs.set(data.hubs || []);
|
||||
}
|
||||
|
||||
function handleNicknameSet(data) {
|
||||
if (data.nickname !== undefined) {
|
||||
nickname.set(data.nickname);
|
||||
}
|
||||
}
|
||||
|
||||
export function requestDiscoveredHubs() {
|
||||
sendWS({ type: 'get_discovered_hubs' });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue