diff --git a/app/soapbox/actions/instance.ts b/app/soapbox/actions/instance.ts index 150e9cc86..994231c12 100644 --- a/app/soapbox/actions/instance.ts +++ b/app/soapbox/actions/instance.ts @@ -59,7 +59,7 @@ export function fetchInstance() { return api(getState).get('/api/v1/instance').then(({ data: instance }: { data: Record }) => { dispatch({ type: INSTANCE_FETCH_SUCCESS, instance }); if (needsNodeinfo(instance)) { - dispatch(fetchNodeinfo()); // Pleroma < 2.1 backwards compatibility + dispatch(fetchNodeinfo() as any); // Pleroma < 2.1 backwards compatibility } }).catch(error => { console.error(error); @@ -73,8 +73,10 @@ export function loadInstance() { return (dispatch: AppDispatch, getState: () => RootState) => { const host = getHost(getState()); - return dispatch(rememberInstance(host)).finally(() => { - return dispatch(fetchInstance()); + if (!host) return new Promise(r => r(null)); + + return dispatch(rememberInstance(host) as any).finally(() => { + return dispatch(fetchInstance() as any); }); }; } diff --git a/app/soapbox/reducers/statuses.ts b/app/soapbox/reducers/statuses.ts index 059e153da..404094b95 100644 --- a/app/soapbox/reducers/statuses.ts +++ b/app/soapbox/reducers/statuses.ts @@ -86,7 +86,7 @@ export const calculateStatus = ( const emojiMap = makeEmojiMap(status.emojis); return status.merge({ - search_index: domParser.parseFromString(searchContent, 'text/html').documentElement.textContent, + search_index: domParser.parseFromString(searchContent, 'text/html').documentElement.textContent || undefined, contentHtml: stripCompatibilityFeatures(emojify(status.content, emojiMap)), spoilerHtml: emojify(escapeTextContentForBrowser(spoilerText), emojiMap), hidden: expandSpoilers ? false : spoilerText.length > 0 || status.sensitive, diff --git a/app/soapbox/storage/kv_store.ts b/app/soapbox/storage/kv_store.ts index 5b7225c0d..941144050 100644 --- a/app/soapbox/storage/kv_store.ts +++ b/app/soapbox/storage/kv_store.ts @@ -1,17 +1,17 @@ import localforage from 'localforage'; interface IKVStore extends LocalForage { - getItemOrError?: (key: string) => Promise, + getItemOrError: (key: string) => Promise, } // localForage // https://localforage.github.io/localForage/#settings-api-config -export const KVStore: IKVStore = localforage.createInstance({ +export const KVStore = localforage.createInstance({ name: 'soapbox', description: 'Soapbox offline data store', driver: localforage.INDEXEDDB, storeName: 'keyvaluepairs', -}); +}) as IKVStore; // localForage returns 'null' when a key isn't found. // In the Redux action flow, we want it to fail harder. diff --git a/app/soapbox/utils/config_db.ts b/app/soapbox/utils/config_db.ts index 1ea8a0b8c..deb5d048a 100644 --- a/app/soapbox/utils/config_db.ts +++ b/app/soapbox/utils/config_db.ts @@ -13,7 +13,7 @@ const find = ( configs: ImmutableList, group: string, key: string, -): Config => { +): Config | undefined => { return configs.find(config => config.isSuperset(ImmutableMap({ group, key })), ); diff --git a/app/soapbox/utils/theme.ts b/app/soapbox/utils/theme.ts index d6225378e..bb83b0111 100644 --- a/app/soapbox/utils/theme.ts +++ b/app/soapbox/utils/theme.ts @@ -61,19 +61,28 @@ function hslToHex(color: Hsl): string { } // Generate accent color from brand color -export const generateAccent = (brandColor: string): string => { - const { h } = rgbToHsl(hexToRgb(brandColor)); +export const generateAccent = (brandColor: string): string | null => { + const rgb = hexToRgb(brandColor); + if (!rgb) return null; + + const { h } = rgbToHsl(rgb); return hslToHex({ h: h - 15, s: 86, l: 44 }); }; const parseShades = (obj: Record, color: string, shades: Record) => { if (typeof shades === 'string') { - const { r, g, b } = hexToRgb(shades); + const rgb = hexToRgb(shades); + if (!rgb) return obj; + + const { r, g, b } = rgb; return obj[`--color-${color}`] = `${r} ${g} ${b}`; } return Object.keys(shades).forEach(shade => { - const { r, g, b } = hexToRgb(shades[shade]); + const rgb = hexToRgb(shades[shade]); + if (!rgb) return; + + const { r, g, b } = rgb; obj[`--color-${color}-${shade}`] = `${r} ${g} ${b}`; }); }; diff --git a/tsconfig.json b/tsconfig.json index fa80d5507..6af5fd813 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "baseUrl": "app/", "sourceMap": true, - "noImplicitAny": true, + "strict": true, "module": "es6", "target": "es5", "jsx": "react",