From 10b6a19e0a90efdeb5658e5582fb79d9d41a6b76 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 17 Apr 2020 18:25:36 -0500 Subject: [PATCH] Obliterate initial-state nonsense --- app/gabsocial/initial_state.js | 15 +------------ app/gabsocial/reducers/compose.js | 2 +- app/gabsocial/reducers/media_attachments.js | 25 +++++++++++++++++++-- public/index.html | 1 - 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/app/gabsocial/initial_state.js b/app/gabsocial/initial_state.js index 90d997c6a..dd47e4e8b 100644 --- a/app/gabsocial/initial_state.js +++ b/app/gabsocial/initial_state.js @@ -1,19 +1,6 @@ 'use strict'; const element = document.getElementById('initial-state'); -const initialState = element && JSON.parse(element.textContent); - -const getMeta = (prop) => initialState && initialState.meta && initialState.meta[prop]; - -export const reduceMotion = getMeta('reduce_motion'); -export const displayMedia = getMeta('display_media'); -export const unfollowModal = getMeta('unfollow_modal'); -export const boostModal = getMeta('boost_modal'); -export const deleteModal = getMeta('delete_modal'); -export const searchEnabled = getMeta('search_enabled'); -export const invitesEnabled = getMeta('invites_enabled'); -export const profile_directory = getMeta('profile_directory'); -export const isStaff = getMeta('is_staff'); -export const unreadCount = getMeta('unread_count'); +const initialState = element ? JSON.parse(element.textContent) : {}; export default initialState; diff --git a/app/gabsocial/reducers/compose.js b/app/gabsocial/reducers/compose.js index 8b9be5744..4bc327192 100644 --- a/app/gabsocial/reducers/compose.js +++ b/app/gabsocial/reducers/compose.js @@ -174,7 +174,7 @@ const privacyPreference = (a, b) => { return order[Math.max(order.indexOf(a), order.indexOf(b), 0)]; }; -const hydrate = (state, hydratedState) => { +const hydrate = (state, hydratedState = ImmutableMap()) => { state = clearAll(state.merge(hydratedState)); if (hydratedState.has('text')) { diff --git a/app/gabsocial/reducers/media_attachments.js b/app/gabsocial/reducers/media_attachments.js index 24119f628..4cc6cf1a2 100644 --- a/app/gabsocial/reducers/media_attachments.js +++ b/app/gabsocial/reducers/media_attachments.js @@ -1,8 +1,29 @@ import { STORE_HYDRATE } from '../actions/store'; -import { Map as ImmutableMap } from 'immutable'; +import { + Map as ImmutableMap, + List as ImmutableList, +} from 'immutable'; const initialState = ImmutableMap({ - accept_content_types: [], + // FIXME: Leave this empty and pull from backend + accept_content_types: ImmutableList([ + '.jpg', + '.jpeg', + '.png', + '.gif', + '.webp', + '.webm', + '.mp4', + '.m4v', + '.mov', + 'image/jpeg', + 'image/png', + 'image/gif', + 'image/webp', + 'video/webm', + 'video/mp4', + 'video/quicktime', + ]), }); export default function meta(state = initialState, action) { diff --git a/public/index.html b/public/index.html index a9a2f73a1..0d941aec3 100644 --- a/public/index.html +++ b/public/index.html @@ -9,7 +9,6 @@ -