diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index ecfd1067..25888038 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -60,7 +60,8 @@ "moveUp": "Move Up", "moveDown": "Move Down", "guest": "Guest", - "versionGate": "This version of Photon supports instances running {{version}} or higher." + "versionGate": "This version of Photon supports instances running {{version}} or higher.", + "checkInboxes": "Check all inboxes" }, "filter": { "location": { diff --git a/src/routes/accounts/+page.svelte b/src/routes/accounts/+page.svelte index 722e6860..53a9d2c7 100644 --- a/src/routes/accounts/+page.svelte +++ b/src/routes/accounts/+page.svelte @@ -14,7 +14,7 @@ import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js' import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte' import { userSettings } from '$lib/settings.js' - import { Button, TextInput } from 'mono-svelte' + import { Button, Badge, Spinner } from 'mono-svelte' import { ArrowLeftOnRectangle, ArrowRightOnRectangle, @@ -29,13 +29,16 @@ Identification, PaintBrush, Plus, + Inbox, } from 'svelte-hero-icons' import { flip } from 'svelte/animate' import { expoOut } from 'svelte/easing' import { t } from '$lib/translations' import Header from '$lib/components/ui/layout/pages/Header.svelte' import FilterTabs from '$lib/components/ui/tabs/FilterTabs.svelte' - import { fly } from 'svelte/transition' + import { fly, slide } from 'svelte/transition' + import { client } from '$lib/lemmy' + import ProgressBar from '$lib/components/ui/ProgressBar.svelte' let debugging = false let debugProfile: Profile | undefined = undefined @@ -46,6 +49,42 @@ } let switching = -2 + + let notifications: Map = new Map() + let checking = false + let progress = 0 + async function checkAllInboxes() { + const profiles = $profileData.profiles.filter((i) => i.jwt != undefined) + progress = 0 + + await Promise.all( + profiles.map( + (profile) => + new Promise(async (res, rej) => { + notifications.set(profile.id, null) + const response = await client({ + auth: profile.jwt, + instanceURL: profile.instance, + }).getUnreadCount() + + progress += 1 / profiles.length + progress = progress + + notifications.set( + profile.id, + response.mentions + response.private_messages + response.replies + ) + notifications = notifications + + res( + response.mentions + response.private_messages + response.replies + ) + }) + ) + ) + + progress = 0 + } @@ -130,8 +169,8 @@
{$t('routes.accounts')}
-
- @@ -141,9 +180,25 @@ {$t('account.addGuest')} {/if} + {#if $profileData.profiles.length > 1} + + {/if}
+ {#if progress != 0} +
+ +
+ {/if} i.instance} let:items> { @@ -155,7 +210,6 @@ {#each items as profile, index (profile.id)}
-
+
+ {#if typeof notifications.get(profile.id) !== 'undefined'} + {@const count = notifications.get(profile.id)} + {#if count === null} + + {:else if count ?? 0 > 0} + + {count} + + {/if} + {/if}