diff options
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/lib/store.js | 5 | ||||
| -rw-r--r-- | ui/lib/store/channels.svelte.js | 18 | ||||
| -rw-r--r-- | ui/routes/(app)/+layout.svelte | 18 | ||||
| -rw-r--r-- | ui/routes/+layout.svelte | 1 |
4 files changed, 19 insertions, 23 deletions
diff --git a/ui/lib/store.js b/ui/lib/store.js index afced4c..57b5cce 100644 --- a/ui/lib/store.js +++ b/ui/lib/store.js @@ -6,9 +6,8 @@ import { Logins } from '$lib/store/logins'; import { STORE_KEY_CHANNELS_DATA } from '$lib/constants'; // Get channelsList content from the local storage -const channelsMetaData = ( - browser && JSON.parse(localStorage.getItem(STORE_KEY_CHANNELS_DATA)) -) || {}; +const channelsMetaData = + (browser && JSON.parse(localStorage.getItem(STORE_KEY_CHANNELS_DATA))) || {}; export const currentUser = writable(null); export const logins = writable(new Logins()); diff --git a/ui/lib/store/channels.svelte.js b/ui/lib/store/channels.svelte.js index 31e9098..9058d86 100644 --- a/ui/lib/store/channels.svelte.js +++ b/ui/lib/store/channels.svelte.js @@ -1,8 +1,7 @@ import { DateTime } from 'luxon'; -import { get } from 'svelte/store' +import { get } from 'svelte/store'; import { STORE_KEY_CHANNELS_DATA, EPOCH_STRING } from '$lib/constants'; - export class Channels { channels = $state([]); @@ -24,7 +23,7 @@ export class Channels { } addChannel(id, name) { - const newChannel = { id, name } + const newChannel = { id, name }; this.channels = [...this.channels, newChannel]; get(this.channelsMetaList).initializeChannel(newChannel); this.sort(); @@ -66,17 +65,14 @@ export class ChannelsMeta { } return { ...ch, - lastReadAt, + lastReadAt }; }); this.channelsMeta = channelsMeta; } writeOutToLocalStorage() { - localStorage.setItem( - STORE_KEY_CHANNELS_DATA, - JSON.stringify(this.channelsMeta) - ); + localStorage.setItem(STORE_KEY_CHANNELS_DATA, JSON.stringify(this.channelsMeta)); } updateLastReadAt(channelId, at) { @@ -100,7 +96,7 @@ export class ChannelsMeta { const channelData = { lastReadAt: null, draft: '', - scrollPosition: null, + scrollPosition: null }; this.channelsMeta[channelId] = channelData; } @@ -113,7 +109,7 @@ export class ChannelsMeta { function objectMap(object, mapFn) { return Object.keys(object).reduce((result, key) => { - result[key] = mapFn(object[key]) - return result + result[key] = mapFn(object[key]); + return result; }, {}); } diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte index 572a551..67fea64 100644 --- a/ui/routes/(app)/+layout.svelte +++ b/ui/routes/(app)/+layout.svelte @@ -8,7 +8,14 @@ import TinyGesture from 'tinygesture'; import { boot, subscribeToEvents } from '$lib/apiServer'; - import { channelsList, channelsMetaList, currentUser, logins, messages, onEvent } from '$lib/store'; + import { + channelsList, + channelsMetaList, + currentUser, + logins, + messages, + onEvent + } from '$lib/store'; import ChannelList from '$lib/components/ChannelList.svelte'; import CreateChannelForm from '$lib/components/CreateChannelForm.svelte'; @@ -117,16 +124,11 @@ const STORE_KEY_LAST_ACTIVE = 'pilcrow:lastActiveChannel'; function getLastActiveChannel() { - return ( - browser && JSON.parse(localStorage.getItem(STORE_KEY_LAST_ACTIVE)) - ); + return browser && JSON.parse(localStorage.getItem(STORE_KEY_LAST_ACTIVE)); } function setLastActiveChannel(channelId) { - browser && localStorage.setItem( - STORE_KEY_LAST_ACTIVE, - JSON.stringify(channelId) - ); + browser && localStorage.setItem(STORE_KEY_LAST_ACTIVE, JSON.stringify(channelId)); } afterNavigate(() => { diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte index 5bccd2f..6c19a95 100644 --- a/ui/routes/+layout.svelte +++ b/ui/routes/+layout.svelte @@ -6,7 +6,6 @@ import logo from '$lib/assets/logo.png'; import { currentUser } from '$lib/store'; - let pageContext = $state({ showMenu: false }); |
