diff --git a/src/components/composer.tsx b/src/components/composer.tsx index 830ff26..b79b676 100644 --- a/src/components/composer.tsx +++ b/src/components/composer.tsx @@ -61,7 +61,7 @@ const Composer: FC = ({ parent, onPost }) => { } const withRateLimit = async (fn: (data: IncomingMessageData) => Promise, data: IncomingMessageData, ms: number = 2000) => { - const last = limiters[data.name] || 0 + const last = limiters[data.name] ?? 0 if ((Date.now() - last) > ms) { await fn(data) diff --git a/src/components/group-invitations.tsx b/src/components/group-invitations.tsx index aef8c2c..d9f8247 100644 --- a/src/components/group-invitations.tsx +++ b/src/components/group-invitations.tsx @@ -90,9 +90,9 @@ const GroupInvitations: FC = ({ group }) => { {invitation.id} {invitation.user.id} - {invitation.uses || 0} - {invitation.limit || 'None'} - {invitation.expiration || 'Never'} + {invitation.uses ?? 0} + {invitation.limit ?? 'None'} + {invitation.expiration ?? 'Never'} {moment(invitation.created).format('MMMM Do YYYY, h:mm:ss a')} ))} diff --git a/src/components/pages/edit-app.tsx b/src/components/pages/edit-app.tsx index 84bef90..5193271 100644 --- a/src/components/pages/edit-app.tsx +++ b/src/components/pages/edit-app.tsx @@ -63,15 +63,15 @@ const EditApp: FC = () => { dispatch(initForm()) dispatch(initField('name', app.name)) - dispatch(initField('about', app.about || '')) - dispatch(initField('websiteUrl', app.websiteUrl || '')) - dispatch(initField('companyName', app.companyName || '')) + dispatch(initField('about', app.about ?? '')) + dispatch(initField('websiteUrl', app.websiteUrl ?? '')) + dispatch(initField('companyName', app.companyName ?? '')) dispatch(initField('version', '')) - dispatch(initField('composerUrl', app.composerUrl || '')) - dispatch(initField('rendererUrl', app.rendererUrl || '')) - dispatch(initField('image', app.imageUrl || '')) - dispatch(initField('coverImage', app.coverImageUrl || '')) - dispatch(initField('iconImage', app.iconImageUrl || '')) + dispatch(initField('composerUrl', app.composerUrl ?? '')) + dispatch(initField('rendererUrl', app.rendererUrl ?? '')) + dispatch(initField('image', app.imageUrl ?? '')) + dispatch(initField('coverImage', app.coverImageUrl ?? '')) + dispatch(initField('iconImage', app.iconImageUrl ?? '')) } }, [app]) diff --git a/src/components/pages/self.tsx b/src/components/pages/self.tsx index 15bbcdb..7bc46ef 100644 --- a/src/components/pages/self.tsx +++ b/src/components/pages/self.tsx @@ -82,11 +82,11 @@ const Self: FC = () => { dispatch(initForm()) dispatch(initField('name', user.name)) - dispatch(initField('about', user.about || '')) + dispatch(initField('about', user.about ?? '')) dispatch(initField('requiresApproval', user.requiresApproval)) dispatch(initField('privacy', user.privacy)) - dispatch(initField('image', user.imageUrl || '')) - dispatch(initField('coverImage', user.coverImageUrl || '')) + dispatch(initField('image', user.imageUrl ?? '')) + dispatch(initField('coverImage', user.coverImageUrl ?? '')) dispatch(initField('theme', user.theme)) dispatch(initField('allowThemeChange', user.settings.allowThemeChange)) } @@ -97,7 +97,7 @@ const Self: FC = () => { return (
- {user.name || user.id} + {user.name ?? user.id} @{user.id} diff --git a/src/reducers/entities.ts b/src/reducers/entities.ts index dfa3925..34d0ced 100644 --- a/src/reducers/entities.ts +++ b/src/reducers/entities.ts @@ -10,8 +10,8 @@ const reducer: Reducer = (state = initialState, switch (action.type) { case 'ENTITIES_SET_ENTITY': { const { type, entity } = action.payload - const collection = state[type] || {} - const existing = collection[entity.id] || {} + const collection = state[type] ?? {} + const existing = collection[entity.id] ?? {} return { ...state, diff --git a/src/reducers/lists.ts b/src/reducers/lists.ts index 74930df..1526453 100644 --- a/src/reducers/lists.ts +++ b/src/reducers/lists.ts @@ -8,7 +8,7 @@ const initialState: EntityListsState = {} const reducer: Reducer = (state = initialState, action) => { switch (action.type) { case 'LISTS_APPEND': - const list = state[action.payload.key] || { + const list = state[action.payload.key] ?? { entities: [], continuation: undefined, checked: 0, diff --git a/src/reducers/requests.ts b/src/reducers/requests.ts index f6a337c..c3260cc 100644 --- a/src/reducers/requests.ts +++ b/src/reducers/requests.ts @@ -8,7 +8,7 @@ const initialState: RequestsState = {} const reducer: Reducer = (state = initialState, action) => { switch (action.type) { case 'REQUESTS_START_REQUEST': { - const request = state[action.payload.id] || {} + const request = state[action.payload.id] ?? {} return { ...state, @@ -21,7 +21,7 @@ const reducer: Reducer = (state = initialState, } } case 'REQUESTS_FINISH_REQUEST': { - const request = state[action.payload.id] || {} + const request = state[action.payload.id] ?? {} return { ...state, diff --git a/src/selectors/index.ts b/src/selectors/index.ts index c8d7b18..7e0ce61 100644 --- a/src/selectors/index.ts +++ b/src/selectors/index.ts @@ -5,9 +5,8 @@ import { AppState } from '../types' export const getNotifications = (state: AppState) => state.notifications export const getRequests = (state: AppState) => state.requests +export const getConfig = (state: AppState) => state.config export const getFetching = createSelector(getRequests, requests => { return values(requests).reduce((fetching, request) => fetching || request.fetching, false) }) - -export const getConfig = (state: AppState) => state.config diff --git a/src/utils/index.ts b/src/utils/index.ts index 225fec7..edae197 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -2,27 +2,17 @@ import getConfig from 'src/config' import themes from 'src/themes' import { - NotificationType, Form, FormValue, Config, ClassDictionary, } from 'src/types' -export function notificationTypeToClassName(type: NotificationType): string { - switch (type) { - case NotificationType.Info: return 'is-info' - case NotificationType.Success: return 'is-success' - case NotificationType.Error: return 'is-danger' - case NotificationType.Welcome: return 'is-success' - } -} - export const objectToQuerystring = (obj: object) => Object.entries(obj).filter(([_, value]) => value !== undefined).map(([name, value]) => `${name}=${value}`).join('&') export function setTitle(title: string, decorate: boolean = true) { if (decorate) { - document.title = `${title} - Flexor` + document.title = `${title} \ Flexor` } else { document.title = title } diff --git a/src/utils/normalization.ts b/src/utils/normalization.ts index 708e9ab..9bc8bfe 100644 --- a/src/utils/normalization.ts +++ b/src/utils/normalization.ts @@ -24,8 +24,8 @@ export interface NormalizeResult { function set(type: EntityType, store: EntityStore, entity?: Entity): string | undefined { if (!entity) return - const collection = store[type] || {} - const existing = collection[entity.id] || {} + const collection = store[type] ?? {} + const existing = collection[entity.id] ?? {} collection[entity.id] = { ...existing, @@ -39,7 +39,7 @@ function set(type: EntityType, store: EntityStore, entity?: Entity): string | un function get(type: EntityType, store: EntityStore, id?: string): Entity | undefined { if (!id) return - const collection = store[type] || {} + const collection = store[type] ?? {} return collection[id] }