diff --git a/src/components/layout/Navbar.svelte b/src/components/layout/Navbar.svelte index cf5b5ec..5a1817e 100644 --- a/src/components/layout/Navbar.svelte +++ b/src/components/layout/Navbar.svelte @@ -4,19 +4,29 @@ import { AppBar, getModalStore, + getToastStore, popup, type ModalSettings, type PopupSettings } from '@skeletonlabs/skeleton'; import Icon from '@iconify/svelte'; import { get } from 'svelte/store'; - import { notificationCount, notificationList, refreshToken, token } from '$lib/Store'; + import { + globalUsername, + notificationCount, + notificationList, + profilePicture, + refreshToken, + token + } from '$lib/Store'; import { t } from '../../i18n'; import Settings from '../popups/Settings.svelte'; import Notifications from '../popups/Notifications.svelte'; + import { createNotificationToast } from '$lib/utils/Toasts'; const loginToken = get(token); const modalStore = getModalStore(); + const toastStore = getToastStore(); const modalPost: ModalSettings = { type: 'component', @@ -48,6 +58,9 @@ function handleLogout() { token.set(''); refreshToken.set(''); + globalUsername.set(''); + profilePicture.set(''); + notificationList.set({ records: [] }); location.reload(); } function openModalPost() { @@ -80,9 +93,11 @@ } else { notificationList.update((value) => { value.records.push(payload); + return value; }); notificationCount.update((value) => value + 1); + toastStore.trigger(createNotificationToast(payload)); } } }); diff --git a/src/components/Login.svelte b/src/components/login/Login.svelte similarity index 96% rename from src/components/Login.svelte rename to src/components/login/Login.svelte index 28fdc57..eb8d23b 100644 --- a/src/components/Login.svelte +++ b/src/components/login/Login.svelte @@ -1,6 +1,6 @@ -
+
{#if imageDataUrl} diff --git a/src/components/modals/ModalChangePwd.svelte b/src/components/modals/ModalChangePwd.svelte index 39d2371..102574e 100644 --- a/src/components/modals/ModalChangePwd.svelte +++ b/src/components/modals/ModalChangePwd.svelte @@ -127,7 +127,7 @@ disabled={!areAllInputsCorrect} on:click={callHandleSubmit} class="btn variant-filled-primary ml-2" - type="submit">{$t('register.button.register')}{$t('modalChangePassword.changeButton')}
diff --git a/src/components/modals/ModalChat.svelte b/src/components/modals/ModalChat.svelte index 63e2809..1a335c2 100644 --- a/src/components/modals/ModalChat.svelte +++ b/src/components/modals/ModalChat.svelte @@ -4,7 +4,7 @@ import { t } from '../../i18n'; import Icon from '@iconify/svelte'; import type { ChatMessage, ChatMessages, ChatStructure } from '$lib/types/Chat'; - import { chatIdNewChat, globalUsername, serverURL, token } from '$lib/Store'; + import { chatIdNewChat, chats, globalUsername, serverURL, token } from '$lib/Store'; import { get } from 'svelte/store'; import { onDestroy, onMount } from 'svelte'; import { getChats, getMessages } from '$lib/utils/Chat'; @@ -50,6 +50,7 @@ onMount(async () => { dataChats = await getChats(); + chats.set(dataChats); copieChats = Object.assign({}, dataChats); if ($chatIdNewChat) { openChat($chatIdNewChat); @@ -153,7 +154,7 @@ on:input={handleChatSearch} /> -
+
    {#each dataChats.records as record (record.chatId)}
  • diff --git a/src/components/modals/ModalCreatePost.svelte b/src/components/modals/ModalCreatePost.svelte index 5f6275a..54aa58a 100644 --- a/src/components/modals/ModalCreatePost.svelte +++ b/src/components/modals/ModalCreatePost.svelte @@ -100,7 +100,7 @@ {/if} {#if imageClick == true} -
    +
    {/if} -
    +
    diff --git a/src/components/modals/ModalNewChat.svelte b/src/components/modals/ModalNewChat.svelte index 35875b2..39be445 100644 --- a/src/components/modals/ModalNewChat.svelte +++ b/src/components/modals/ModalNewChat.svelte @@ -6,6 +6,8 @@ import { onMount } from 'svelte'; import Icon from '@iconify/svelte'; import { createChat } from '$lib/utils/Chat'; + import { get } from 'svelte/store'; + import { chats } from '$lib/Store'; const modalStore = getModalStore(); let inputField: HTMLInputElement; @@ -31,6 +33,9 @@ const usersRequest: UsersForSearch | undefined = await userSearch(userInput, toastStore); if (usersRequest) { users = usersRequest.records; + const usernamesToRemove = new Set(get(chats).records.map((chat) => chat.user.username)); + + users = users.filter((user) => !usernamesToRemove.has(user.username)); } } } @@ -117,11 +122,7 @@ maxlength="256" disabled={sendDisabled} /> - {/if}
{#if loginToken != ''} -
+