Export fallback content type and use it as default in WebUI

master
Thibaut Girka 6 years ago committed by ThibG
parent dd5bf40b97
commit 56245a2a72
  1. 6
      app/javascript/flavours/glitch/reducers/compose.js
  2. 1
      app/javascript/flavours/glitch/util/initial_state.js
  3. 1
      app/serializers/initial_state_serializer.rb

@ -45,7 +45,7 @@ import { REDRAFT } from 'flavours/glitch/actions/statuses';
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable'; import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';
import uuid from 'flavours/glitch/util/uuid'; import uuid from 'flavours/glitch/util/uuid';
import { privacyPreference } from 'flavours/glitch/util/privacy_preference'; import { privacyPreference } from 'flavours/glitch/util/privacy_preference';
import { me } from 'flavours/glitch/util/initial_state'; import { me, defaultContentType } from 'flavours/glitch/util/initial_state';
import { overwrite } from 'flavours/glitch/util/js_helpers'; import { overwrite } from 'flavours/glitch/util/js_helpers';
import { unescapeHTML } from 'flavours/glitch/util/html'; import { unescapeHTML } from 'flavours/glitch/util/html';
import { recoverHashtags } from 'flavours/glitch/util/hashtag'; import { recoverHashtags } from 'flavours/glitch/util/hashtag';
@ -67,7 +67,7 @@ const initialState = ImmutableMap({
spoiler: false, spoiler: false,
spoiler_text: '', spoiler_text: '',
privacy: null, privacy: null,
content_type: 'text/plain', content_type: defaultContentType || 'text/plain',
text: '', text: '',
focusDate: null, focusDate: null,
caretPosition: null, caretPosition: null,
@ -143,6 +143,7 @@ function apiStatusToTextHashtags (state, status) {
function clearAll(state) { function clearAll(state) {
return state.withMutations(map => { return state.withMutations(map => {
map.set('text', ''); map.set('text', '');
if (defaultContentType) map.set('content_type', defaultContentType);
map.set('spoiler', false); map.set('spoiler', false);
map.set('spoiler_text', ''); map.set('spoiler_text', '');
map.set('is_submitting', false); map.set('is_submitting', false);
@ -354,6 +355,7 @@ export default function compose(state = initialState, action) {
case COMPOSE_RESET: case COMPOSE_RESET:
return state.withMutations(map => { return state.withMutations(map => {
map.set('in_reply_to', null); map.set('in_reply_to', null);
if (defaultContentType) map.set('content_type', defaultContentType);
map.set('text', ''); map.set('text', '');
map.set('spoiler', false); map.set('spoiler', false);
map.set('spoiler_text', ''); map.set('spoiler_text', '');

@ -27,5 +27,6 @@ export const invitesEnabled = getMeta('invites_enabled');
export const version = getMeta('version'); export const version = getMeta('version');
export const mascot = getMeta('mascot'); export const mascot = getMeta('mascot');
export const isStaff = getMeta('is_staff'); export const isStaff = getMeta('is_staff');
export const defaultContentType = getMeta('default_content_type');
export default initialState; export default initialState;

@ -47,6 +47,7 @@ class InitialStateSerializer < ActiveModel::Serializer
store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers
store[:reduce_motion] = object.current_account.user.setting_reduce_motion store[:reduce_motion] = object.current_account.user.setting_reduce_motion
store[:is_staff] = object.current_account.user.staff? store[:is_staff] = object.current_account.user.staff?
store[:default_content_type] = object.current_account.user.setting_default_content_type
end end
store store

Loading…
Cancel
Save