Skip to content

Commit

Permalink
Reorganize files
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshino committed Dec 31, 2024
1 parent 0cf25aa commit 962e118
Show file tree
Hide file tree
Showing 27 changed files with 51 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import EmptyState from '$lib/components/common/empty-state.svelte';
import InfiniteScroll from '$lib/components/common/infinite-scroll.svelte';
import { selectAssetsView } from '$lib/services/contents/draft/editor';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
/**
* @typedef {object} Props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
allCloudStorageServices,
allStockPhotoServices,
} from '$lib/services/integrations/media-libraries';
import { prefs } from '$lib/services/prefs';
import { normalize } from '$lib/services/search';
import { prefs } from '$lib/services/user/prefs';
/**
* @typedef {object} Props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
} from '$lib/services/assets';
import { showUploadAssetsDialog } from '$lib/services/assets/view';
import { backend } from '$lib/services/backends';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
/**
* @typedef {object} Props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
translatorApiKeyDialogState,
} from '$lib/services/contents/draft/editor';
import { translator } from '$lib/services/integrations/translators';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
const { serviceId, serviceLabel, developerURL, apiKeyURL, apiKeyPattern } = $derived(
$translator ?? /** @type {TranslationService} */ ({}),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/contents/details/pane-header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import { revertChanges, toggleLocale } from '$lib/services/contents/draft/update';
import { getEntryPreviewURL, getEntryRepoBlobURL } from '$lib/services/contents/entry';
import { defaultI18nConfig, getLocaleLabel } from '$lib/services/contents/i18n';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
/**
* @typedef {object} Props
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/contents/details/toolbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import { getAssociatedAssets } from '$lib/services/contents/entry/assets';
import { getEntrySummary } from '$lib/services/contents/entry/summary';
import { defaultI18nConfig, getLocaleLabel } from '$lib/services/contents/i18n';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
let showValidationToast = $state(false);
let showDeleteDialog = $state(false);
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/entrance/entrance-page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import { inAuthPopup } from '$lib/services/backends/shared/auth';
import { siteConfig, siteConfigError } from '$lib/services/config';
import { dataLoaded, dataLoadedProgress } from '$lib/services/contents';
import { prefs, prefsError } from '$lib/services/prefs';
import { signInError, unauthenticated, user } from '$lib/services/user';
import { user } from '$lib/services/user';
import { signInError, unauthenticated } from '$lib/services/user/auth';
import { prefs, prefsError } from '$lib/services/user/prefs';
$effect(() => {
$announcedPageStatus = $_('welcome_to_sveltia_cms');
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/entrance/sign-in.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
signInError,
signInManually,
unauthenticated,
} from '$lib/services/user';
} from '$lib/services/user/auth';
import { siteConfig } from '$lib/services/config';
import { allBackendServices } from '$lib/services/backends';
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/global/toolbar/items/account-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import PrefsDialog from '$lib/components/prefs/prefs-dialog.svelte';
import { goto, openProductionSite } from '$lib/services/app/navigation';
import { backend, backendName } from '$lib/services/backends';
import { prefs } from '$lib/services/prefs';
import { signOut, user } from '$lib/services/user';
import { user } from '$lib/services/user';
import { signOut } from '$lib/services/user/auth';
import { prefs } from '$lib/services/user/prefs';
/** @type {MenuButton | undefined} */
let menuButton = $state();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/global/toolbar/items/help-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { _ } from 'svelte-i18n';
import ShortcutsDialog from '$lib/components/keyboard-shortcuts/shortcuts-dialog.svelte';
import { version } from '$lib/services/app';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
/** @type {MenuButton | undefined} */
let menuButton = $state();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { _ } from 'svelte-i18n';
import { backend, backendName, isLastCommitPublished } from '$lib/services/backends';
import { siteConfig } from '$lib/services/config';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
const { backend: { automatic_deployments: autoDeployEnabled = undefined } = {} } = $derived(
$siteConfig ?? /** @type {SiteConfig} */ ({}),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/prefs/panels/accessibility-panel.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { Switch, TabPanel } from '@sveltia/ui';
import { _ } from 'svelte-i18n';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
/**
* @typedef {object} Props
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/prefs/panels/advanced-panel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Switch, TabPanel, TextInput } from '@sveltia/ui';
import { _ } from 'svelte-i18n';
import { siteConfig } from '$lib/services/config';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
/**
* @typedef {object} Props
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/prefs/panels/appearance-panel.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { SelectButton, SelectButtonGroup, TabPanel } from '@sveltia/ui';
import { _ } from 'svelte-i18n';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
/**
* @typedef {object} Props
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/prefs/panels/contents-panel.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { Switch, TabPanel } from '@sveltia/ui';
import { _ } from 'svelte-i18n';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
/**
* @typedef {object} Props
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/prefs/panels/languages-panel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { siteConfig } from '$lib/services/config';
import { getLocaleLabel } from '$lib/services/contents/i18n';
import { allTranslationServices } from '$lib/services/integrations/translators';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
/**
* @typedef {object} Props
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/prefs/panels/media-panel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { TabPanel, TextInput } from '@sveltia/ui';
import DOMPurify from 'isomorphic-dompurify';
import { _ } from 'svelte-i18n';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
import { allStockPhotoServices } from '$lib/services/integrations/media-libraries';
/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/app/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { initLocales } from '@sveltia/ui';
import { getPathInfo } from '@sveltia/utils/file';
import { addMessages, getLocaleFromNavigator } from 'svelte-i18n';
import { get } from 'svelte/store';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';

/**
* Load strings and initialize the locales.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/assets/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { compare } from '@sveltia/utils/string';
import equal from 'fast-deep-equal';
import { _, locale as appLocale } from 'svelte-i18n';
import { derived, get, writable } from 'svelte/store';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
import { siteConfig } from '$lib/services/config';
import { backend } from '$lib/services/backends';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import merge from 'deepmerge';
import { _ } from 'svelte-i18n';
import { get, writable } from 'svelte/store';
import YAML from 'yaml';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';
import { getI18nConfig } from '$lib/services/contents/i18n';
import { getCollection, selectedCollection } from '$lib/services/contents/collection';
import { allEntryFolders } from '$lib/services/contents';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/contents/collection/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getFilesByEntry } from '$lib/services/contents/collection/files';
import { getFieldConfig, getPropertyValue } from '$lib/services/contents/entry/fields';
import { getEntrySummary } from '$lib/services/contents/entry/summary';
import { getDate } from '$lib/services/contents/widgets/date-time/helper';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';

/**
* @see https://decapcms.org/docs/configuration-options/#sortable_fields
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/contents/draft/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { get, writable } from 'svelte/store';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';

/**
* @type {import('svelte/store').Writable<EntryDraft | null | undefined>}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/contents/draft/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '$lib/services/contents/draft/editor';
import { getFieldConfig } from '$lib/services/contents/entry/fields';
import { translator } from '$lib/services/integrations/translators';
import { prefs } from '$lib/services/prefs';
import { prefs } from '$lib/services/user/prefs';

/**
* Update a flatten object with new properties by adding, updating and deleting properties.
Expand Down
File renamed without changes.
24 changes: 3 additions & 21 deletions src/lib/services/user.js → src/lib/services/user/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,10 @@ import { isObject } from '@sveltia/utils/object';
import { LocalStorage } from '@sveltia/utils/storage';
import { _ } from 'svelte-i18n';
import { get, writable } from 'svelte/store';
import { dataLoaded } from '$lib/services/contents';
import { siteConfig } from '$lib/services/config';
import { backend, backendName } from '$lib/services/backends';

/**
* @type {import('svelte/store').Writable<User | null | undefined>}
*/
export const user = writable();

user.subscribe((_user) => {
(async () => {
try {
if (_user) {
await LocalStorage.set('sveltia-cms.user', _user);
} else if (_user === null) {
await LocalStorage.delete('sveltia-cms.user');
}
} catch {
//
}
})();
});
import { siteConfig } from '$lib/services/config';
import { dataLoaded } from '$lib/services/contents';
import { user } from '$lib/services/user';

/**
* @type {import('svelte/store').Writable<{ message: string, canRetry: boolean }>}
Expand Down
21 changes: 21 additions & 0 deletions src/lib/services/user/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { LocalStorage } from '@sveltia/utils/storage';
import { writable } from 'svelte/store';

/**
* @type {import('svelte/store').Writable<User | null | undefined>}
*/
export const user = writable();

user.subscribe((_user) => {
(async () => {
try {
if (_user) {
await LocalStorage.set('sveltia-cms.user', _user);
} else if (_user === null) {
await LocalStorage.delete('sveltia-cms.user');
}
} catch {
//
}
})();
});
File renamed without changes.

0 comments on commit 962e118

Please sign in to comment.