diff --git a/src/lib/utils/rooms.ts b/src/lib/utils/rooms.ts index 667a7ab..3bf5371 100644 --- a/src/lib/utils/rooms.ts +++ b/src/lib/utils/rooms.ts @@ -41,9 +41,9 @@ function updateRoomStore(rooms: RoomI[], serverURL: string = get(selectedServer) }); } -async function getRoomIdsIfEmpty(server: string, roomIds: string[]): Promise { +async function getRoomIdsByIdentity(server: string, roomIds: string[]): Promise { const idc = getCommitment(); - if (roomIds.length < 1 && idc) { + if (idc) { return await getRoomIdsByIdentityCommitment(server); } return roomIds; @@ -66,7 +66,7 @@ export async function updateRooms( server: string = get(selectedServer), roomIds: string[] = [] ): Promise { - roomIds = await getRoomIdsIfEmpty(server, roomIds); + roomIds = await getRoomIdsByIdentity(server, roomIds); if (roomIds.length > 0) { const rooms = await fetchRoomsByIds(server, roomIds); const acceptedRoomNames = extractRoomNames(rooms); @@ -85,6 +85,7 @@ export async function updateRooms( } export function updateMessages(server: string, roomId: string) { + console.debug('updating messages'); getMessages(server, roomId).then((messages) => { messageStore.update((store) => { store[roomId] = messages; @@ -112,14 +113,20 @@ export function addMessageToRoom(roomId: string, data: MessageI) { } // Add the new message + const test = [...currentStore[roomId]]; + console.log('oldmsgs', test); + console.log('newmsg', data); + currentStore[roomId] = [...currentStore[roomId], data]; + console.log('allmsgs', currentStore[roomId]); // Trim messages to the last 500 if (currentStore[roomId].length > 500) { currentStore[roomId] = currentStore[roomId].slice(-500); } - - return { ...currentStore }; + const result = { ...currentStore }; + console.log(result); + return result; }); } diff --git a/src/routes/chat/ChatInputPrompt.svelte b/src/routes/chat/ChatInputPrompt.svelte index 83720b5..cd3e327 100644 --- a/src/routes/chat/ChatInputPrompt.svelte +++ b/src/routes/chat/ChatInputPrompt.svelte @@ -13,7 +13,6 @@ import { getIdentity, clearMessageHistory } from '$lib/utils'; import Send from 'svelte-material-icons/Send.svelte'; import { decrypt, encrypt } from '$lib/crypto/crypto'; - import { onMount } from 'svelte'; export let socket: Socket; export let connected: boolean; @@ -198,7 +197,7 @@ } function onPromptKeydown(event: KeyboardEvent): void { - if (['Enter'].includes(event.key)) { + if (['Enter'].includes(event.key) && !event.shiftKey) { const value = (event.currentTarget as HTMLInputElement).value; event.preventDefault(); if (value.startsWith('/')) { @@ -223,16 +222,14 @@ placeholder={placeholderText()} rows="1" on:keydown={onPromptKeydown} - disabled={!canSendMessage} - /> + disabled={!canSendMessage} />