feat: wire delete_message, update_profile, add_contact into frontend UI

This commit is contained in:
2026-04-18 01:29:36 -04:00
parent fbe37d8310
commit 47ec72defd
3 changed files with 137 additions and 6 deletions

View File

@@ -117,6 +117,23 @@
} catch (e) { err = String(e); }
}
async function deleteMessage(msgId: string) {
err = '';
try {
await cmd('delete_message', { messageId: msgId });
messages = messages.filter(m => full(m.id) !== msgId);
} catch (e) { err = String(e); }
}
async function updateProfile(fields: { username?: string; avatar?: string }) {
user = await cmd<User>('update_profile', fields);
}
async function addContact(userId: string) {
await cmd('add_contact', { userId });
contacts = await cmd<User[]>('get_contacts').catch(() => []);
}
onMount(init);
onDestroy(async () => {
if (subId) await cmd('unsubscribe_room', { subId }).catch(() => {});
@@ -152,13 +169,17 @@
onCreateRoom={createRoom}
onSignout={signout}
onShowMenu={showMenu}
onUpdateProfile={updateProfile}
onAddContact={addContact}
/>
<ChatMain
{activeRoom}
{messages}
{user}
{err}
bind:fMsg
onSendMessage={sendMessage}
onDeleteMessage={deleteMessage}
onShowMenu={showMenu}
/>
</div>