diff --git a/packages/pl-fe/package.json b/packages/pl-fe/package.json index 99aedd16a..49f326371 100644 --- a/packages/pl-fe/package.json +++ b/packages/pl-fe/package.json @@ -87,7 +87,6 @@ "fuzzysort": "^3.1.0", "graphemesplit": "^2.4.4", "html-react-parser": "^5.1.18", - "immutable": "^4.3.7", "intersection-observer": "^0.12.2", "intl-messageformat": "^10.5.14", "intl-pluralrules": "^2.0.1", diff --git a/packages/pl-fe/src/actions/compose.ts b/packages/pl-fe/src/actions/compose.ts index 051d621c5..d3cddcb7c 100644 --- a/packages/pl-fe/src/actions/compose.ts +++ b/packages/pl-fe/src/actions/compose.ts @@ -318,7 +318,7 @@ const needsDescriptions = (state: RootState, composeId: string) => { const media = state.compose[composeId]!.media_attachments; const missingDescriptionModal = useSettingsStore.getState().settings.missingDescriptionModal; - const hasMissing = media.filter(item => !item.description).size > 0; + const hasMissing = media.filter(item => !item.description).length > 0; return missingDescriptionModal && hasMissing; }; @@ -357,7 +357,7 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) => return; } - if ((!status || !status.length) && media.size === 0) { + if ((!status || !status.length) && media.length === 0) { return; } @@ -392,7 +392,7 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) => status, in_reply_to_id: compose.in_reply_to || undefined, quote_id: compose.quote || undefined, - media_ids: media.map(item => item.id).toArray(), + media_ids: media.map(item => item.id), sensitive: compose.sensitive, spoiler_text: compose.spoiler_text, visibility: compose.privacy, @@ -471,7 +471,7 @@ const uploadCompose = (composeId: string, files: FileList, intl: IntlShape) => const progress = new Array(files.length).fill(0); let total = Array.from(files).reduce((a, v) => a + v.size, 0); - const mediaCount = media ? media.size : 0; + const mediaCount = media ? media.length : 0; if (files.length + mediaCount > attachmentLimit) { toast.error(messages.uploadErrorLimit); @@ -726,7 +726,7 @@ const insertIntoTagHistory = (composeId: string, recognizedTags: Array, tex .map(tag => tag.name); const intersectedOldHistory = oldHistory.filter(name => names.findIndex(newName => newName.toLowerCase() === name.toLowerCase()) === -1); - names.push(...intersectedOldHistory.toJS()); + names.push(...intersectedOldHistory); const newHistory = names.slice(0, 1000); diff --git a/packages/pl-fe/src/actions/pl-fe.ts b/packages/pl-fe/src/actions/pl-fe.ts index 80b0ea886..6a81db1d9 100644 --- a/packages/pl-fe/src/actions/pl-fe.ts +++ b/packages/pl-fe/src/actions/pl-fe.ts @@ -1,7 +1,8 @@ import { createSelector } from 'reselect'; +import * as v from 'valibot'; import { getHost } from 'pl-fe/actions/instance'; -import { normalizePlFeConfig } from 'pl-fe/normalizers/pl-fe/pl-fe-config'; +import { plFeConfigSchema } from 'pl-fe/normalizers/pl-fe/pl-fe-config'; import KVStore from 'pl-fe/storage/kv-store'; import { useSettingsStore } from 'pl-fe/stores/settings'; @@ -17,10 +18,8 @@ const PLFE_CONFIG_REMEMBER_SUCCESS = 'PLFE_CONFIG_REMEMBER_SUCCESS' as const; const getPlFeConfig = createSelector([ (state: RootState) => state.plfe, -], (plfe) => { - // Do some additional normalization with the state - return normalizePlFeConfig(plfe); -}); +// Do some additional normalization with the state +], (plfe) => v.parse(plFeConfigSchema, plfe)); const rememberPlFeConfig = (host: string | null) => (dispatch: AppDispatch) => { diff --git a/packages/pl-fe/src/actions/timelines.ts b/packages/pl-fe/src/actions/timelines.ts index 287c3425f..dfc5f3a12 100644 --- a/packages/pl-fe/src/actions/timelines.ts +++ b/packages/pl-fe/src/actions/timelines.ts @@ -28,7 +28,7 @@ const processTimelineUpdate = (timeline: string, status: BaseStatus) => (dispatch: AppDispatch, getState: () => RootState) => { const me = getState().me; const ownStatus = status.account?.id === me; - const hasPendingStatuses = !getState().pending_statuses.isEmpty(); + const hasPendingStatuses = !!getState().pending_statuses.length; const columnSettings = useSettingsStore.getState().settings.timelines[timeline]; const shouldSkipQueue = shouldFilter({ diff --git a/packages/pl-fe/src/components/modal-root.tsx b/packages/pl-fe/src/components/modal-root.tsx index a9839c65c..be0eb10fc 100644 --- a/packages/pl-fe/src/components/modal-root.tsx +++ b/packages/pl-fe/src/components/modal-root.tsx @@ -22,7 +22,7 @@ const checkComposeContent = (compose?: Compose) => !!compose && [ compose.editorState && compose.editorState.length > 0, compose.spoiler_text.length > 0, - compose.media_attachments.size > 0, + compose.media_attachments.length > 0, compose.poll !== null, ].some(check => check === true); diff --git a/packages/pl-fe/src/components/navlinks.tsx b/packages/pl-fe/src/components/navlinks.tsx index ee84fd150..8a49c5ef0 100644 --- a/packages/pl-fe/src/components/navlinks.tsx +++ b/packages/pl-fe/src/components/navlinks.tsx @@ -16,7 +16,7 @@ const Navlinks: React.FC = ({ type }) => { return (