Skip to content

Commit 6d4d3a3

Browse files
committed
fix(store): split list & lists store into dedicated files + model
1 parent 5499c32 commit 6d4d3a3

13 files changed

+243
-237
lines changed

src/components/views/panel/MoviePanel.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ import {
1313
PanelButtonsOption,
1414
type PanelButtonsOptions,
1515
} from '~/components/views/panel/use-panel-buttons';
16-
import { NotificationService } from '~/services/notification.service';
17-
import { ResolveExternalLinks } from '~/settings/external.links';
18-
import { useAppStateStoreRefs } from '~/stores/app-state.store';
1916
import {
2017
DefaultListId,
2118
DefaultLists,
2219
type ListEntity,
2320
ListType,
24-
useListsStoreRefs,
25-
useListStore,
26-
} from '~/stores/data/list.store';
21+
} from '~/models/list.model';
22+
import { NotificationService } from '~/services/notification.service';
23+
import { ResolveExternalLinks } from '~/settings/external.links';
24+
import { useAppStateStoreRefs } from '~/stores/app-state.store';
25+
import { useListStore } from '~/stores/data/list.store';
26+
import { useListsStoreRefs } from '~/stores/data/lists.store';
2727
import { useMovieStore, useMovieStoreRefs } from '~/stores/data/movie.store';
2828
import { useWatchingStore, useWatchingStoreRefs } from '~/stores/data/watching.store';
2929
import { useExtensionSettingsStoreRefs } from '~/stores/settings/extension.store';

src/components/views/panel/MoviePanelButtons.vue

+2-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@ import {
1515
type PanelButtonsOptions,
1616
usePanelButtons,
1717
} from '~/components/views/panel/use-panel-buttons';
18-
import {
19-
type ListEntity,
20-
ListType,
21-
useListsStore,
22-
useListsStoreRefs,
23-
} from '~/stores/data/list.store';
18+
import { type ListEntity, ListType } from '~/models/list.model';
19+
import { useListsStore, useListsStoreRefs } from '~/stores/data/lists.store';
2420
import { useI18n } from '~/utils/i18n.utils';
2521
2622
const props = defineProps({

src/components/views/panel/ShowPanel.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ import {
1414
PanelButtonsOption,
1515
type PanelButtonsOptions,
1616
} from '~/components/views/panel/use-panel-buttons';
17-
import { NotificationService } from '~/services/notification.service';
18-
import { ResolveExternalLinks } from '~/settings/external.links';
19-
import { useAppStateStoreRefs } from '~/stores/app-state.store';
2017
import {
2118
DefaultListId,
2219
DefaultLists,
2320
type ListEntity,
2421
ListType,
25-
useListsStoreRefs,
26-
useListStore,
27-
} from '~/stores/data/list.store';
22+
} from '~/models/list.model';
23+
import { NotificationService } from '~/services/notification.service';
24+
import { ResolveExternalLinks } from '~/settings/external.links';
25+
import { useAppStateStoreRefs } from '~/stores/app-state.store';
26+
import { useListStore } from '~/stores/data/list.store';
27+
import { useListsStoreRefs } from '~/stores/data/lists.store';
2828
import { useShowStore } from '~/stores/data/show.store';
2929
import { useWatchingStore, useWatchingStoreRefs } from '~/stores/data/watching.store';
3030
import { useExtensionSettingsStoreRefs } from '~/stores/settings/extension.store';

src/components/views/panel/ShowPanelButtons.vue

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ import {
2121
type SeasonProgress,
2222
type ShowProgress,
2323
} from '~/models/list-scroll.model';
24-
import {
25-
type ListEntity,
26-
ListType,
27-
useListsStore,
28-
useListsStoreRefs,
29-
} from '~/stores/data/list.store';
24+
import { type ListEntity, ListType } from '~/models/list.model';
25+
import { useListsStore, useListsStoreRefs } from '~/stores/data/lists.store';
3026
import { useI18n } from '~/utils/i18n.utils';
3127
3228
const props = defineProps({

src/components/views/settings/SettingsExport.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import IconDownload from '~/components/icons/IconDownload.vue';
1111
import IconLoadingDots from '~/components/icons/IconLoadingDots.vue';
1212
import SettingsFormItem from '~/components/views/settings/SettingsFormItem.vue';
1313
14-
import { PageSize } from '~/models/page-size.model';
15-
import { Logger } from '~/services/logger.service';
16-
import { NotificationService } from '~/services/notification.service';
17-
import { TraktService } from '~/services/trakt.service';
1814
import {
1915
isDefaultList,
2016
type ListEntity,
2117
ListType,
2218
type ListTypes,
23-
useListsStoreRefs,
24-
} from '~/stores/data/list.store';
19+
} from '~/models/list.model';
20+
import { PageSize } from '~/models/page-size.model';
21+
import { Logger } from '~/services/logger.service';
22+
import { NotificationService } from '~/services/notification.service';
23+
import { TraktService } from '~/services/trakt.service';
24+
import { useListsStoreRefs } from '~/stores/data/lists.store';
2525
import { useAuthSettingsStoreRefs } from '~/stores/settings/auth.store';
2626
import { useI18n } from '~/utils/i18n.utils';
2727

src/components/views/settings/SettingsTabs.vue

+3-7
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ import IconClose from '~/components/icons/IconCloseSmall.vue';
1515
import IconPencil from '~/components/icons/IconPencil.vue';
1616
1717
import SettingsFormItem from '~/components/views/settings/SettingsFormItem.vue';
18+
import { type ListEntity, ListType } from '~/models/list.model';
1819
import { loadingHysteresisOptions } from '~/models/loading-hysteresis.model';
1920
import { pageSizeOptions, pageSizeOptionsWithZero } from '~/models/page-size.model';
2021
import { ProgressType } from '~/models/progress-type.model';
2122
import { Route } from '~/models/router.model';
2223
import { useCalendarStoreRefs } from '~/stores/data/calendar.store';
2324
import { useHistoryStoreRefs } from '~/stores/data/history.store';
24-
import {
25-
type ListEntity,
26-
ListType,
27-
useListsStore,
28-
useListsStoreRefs,
29-
useListStoreRefs,
30-
} from '~/stores/data/list.store';
25+
import { useListStoreRefs } from '~/stores/data/list.store';
26+
import { useListsStore, useListsStoreRefs } from '~/stores/data/lists.store';
3127
import { useRatingsStoreRefs } from '~/stores/data/ratings.store';
3228
import { useSearchStoreRefs } from '~/stores/data/search.store';
3329
import { useAuthSettingsStoreRefs } from '~/stores/settings/auth.store';

src/components/views/watchlist/WatchlistComponent.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script lang="ts" setup>
22
import { onMounted, watch } from 'vue';
33
4+
import type { AnyList, AnyListDateTypes } from '~/models/list.model';
5+
46
import FloatingButton from '~/components/common/buttons/FloatingButton.vue';
57
import { useBackToTop } from '~/components/common/buttons/use-back-to-top';
68
import ListScroll from '~/components/common/list/ListScroll.vue';
@@ -15,13 +17,11 @@ import { Route } from '~/models/router.model';
1517
import { useAppStateStoreRefs } from '~/stores/app-state.store';
1618
import { useActivityStore } from '~/stores/data/activity.store';
1719
import {
18-
type AnyList,
1920
anyListDateGetter,
20-
type AnyListDateTypes,
21-
useListsStoreRefs,
2221
useListStore,
2322
useListStoreRefs,
2423
} from '~/stores/data/list.store';
24+
import { useListsStoreRefs } from '~/stores/data/lists.store';
2525
import { useI18n } from '~/utils/i18n.utils';
2626
import { useActiveAndDocumentVisible, watchUserChange } from '~/utils/store.utils';
2727
import { useWatchActivated } from '~/utils/vue.utils';

src/components/views/watchlist/WatchlistNavbar.vue

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@ import ButtonLinkExternal from '~/components/common/buttons/ButtonLinkExternal.v
77
import NavbarPageSizeSelect from '~/components/common/navbar/NavbarPageSizeSelect.vue';
88
import IconLoop from '~/components/icons/IconLoop.vue';
99
10+
import { type ListEntity, ListType } from '~/models/list.model';
1011
import { ResolveExternalLinks } from '~/settings/external.links';
11-
import {
12-
type ListEntity,
13-
ListType,
14-
useListsStore,
15-
useListsStoreRefs,
16-
useListStoreRefs,
17-
} from '~/stores/data/list.store';
12+
import { useListStoreRefs } from '~/stores/data/list.store';
13+
import { useListsStore, useListsStoreRefs } from '~/stores/data/lists.store';
1814
import { useAuthSettingsStoreRefs } from '~/stores/settings/auth.store';
1915
import { useI18n } from '~/utils/i18n.utils';
2016
import {

src/models/list.model.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { TraktCollection, TraktFavoriteItem, TraktListItem, TraktUser, TraktWatchlist } from '@dvcol/trakt-http-client/models';
2+
3+
import type { ListScrollItemType } from '~/models/list-scroll.model';
4+
5+
export type AnyList =
6+
| TraktListItem
7+
| TraktWatchlist
8+
| TraktFavoriteItem
9+
| (TraktCollection & { id: number | string; type?: typeof ListScrollItemType.Loading });
10+
11+
export const ListType = {
12+
List: 'list',
13+
Collaboration: 'collaboration',
14+
Collection: 'collection',
15+
Watchlist: 'watchlist',
16+
Favorites: 'favorites',
17+
History: 'history',
18+
} as const;
19+
20+
export type ListTypes = (typeof ListType)[keyof typeof ListType];
21+
22+
export type ListEntity = {
23+
type: ListTypes;
24+
id: number | string | DefaultListIds;
25+
name: string;
26+
owner?: TraktUser;
27+
scope?: 'movies' | 'shows';
28+
};
29+
30+
export type AnyListDateTypes = 'listed_at' | 'last_collected_at' | 'collected_at';
31+
32+
export const DefaultListId = {
33+
Watchlist: 'watchlist',
34+
Favorites: 'favorites',
35+
MovieCollection: 'movie-collection',
36+
ShowCollection: 'show-collection',
37+
History: 'history',
38+
} as const;
39+
40+
export type DefaultListIds = (typeof DefaultListId)[keyof typeof DefaultListId];
41+
42+
export const DefaultLists = {
43+
Watchlist: { type: ListType.Watchlist, id: DefaultListId.Watchlist, name: 'list_type__watchlist' },
44+
Favorites: { type: ListType.Favorites, id: DefaultListId.Favorites, name: 'list_type__favorites' },
45+
MovieCollection: { type: ListType.Collection, id: DefaultListId.MovieCollection, scope: 'movies', name: 'list_type__collection_movie' },
46+
ShowCollection: { type: ListType.Collection, id: DefaultListId.ShowCollection, scope: 'shows', name: 'list_type__collection_show' },
47+
} as const satisfies Record<string, ListEntity>;
48+
49+
export const DefaultListsTypes: ListTypes[] = Object.values(DefaultLists).map(l => l.type);
50+
51+
export const isDefaultList = (list: ListEntity | ListTypes) => DefaultListsTypes.includes(typeof list === 'string' ? list : list.type);

0 commit comments

Comments
 (0)