]> cat aescling's git repositories - mastodon.git/commitdiff
Export fallback content type and use it as default in WebUI
authorThibaut Girka <thib@sitedethib.com>
Fri, 17 May 2019 08:52:27 +0000 (10:52 +0200)
committerThibG <thib@sitedethib.com>
Fri, 17 May 2019 21:51:14 +0000 (23:51 +0200)
app/javascript/flavours/glitch/reducers/compose.js
app/javascript/flavours/glitch/util/initial_state.js
app/serializers/initial_state_serializer.rb

index 82facb1e2ece7cdba9ccb79be0e9bea6df19d87c..c0c2fc5473f275f0240994480290c60ddd97be17 100644 (file)
@@ -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 uuid from 'flavours/glitch/util/uuid';
 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 { unescapeHTML } from 'flavours/glitch/util/html';
 import { recoverHashtags } from 'flavours/glitch/util/hashtag';
@@ -67,7 +67,7 @@ const initialState = ImmutableMap({
   spoiler: false,
   spoiler_text: '',
   privacy: null,
-  content_type: 'text/plain',
+  content_type: defaultContentType || 'text/plain',
   text: '',
   focusDate: null,
   caretPosition: null,
@@ -143,6 +143,7 @@ function apiStatusToTextHashtags (state, status) {
 function clearAll(state) {
   return state.withMutations(map => {
     map.set('text', '');
+    if (defaultContentType) map.set('content_type', defaultContentType);
     map.set('spoiler', false);
     map.set('spoiler_text', '');
     map.set('is_submitting', false);
@@ -354,6 +355,7 @@ export default function compose(state = initialState, action) {
   case COMPOSE_RESET:
     return state.withMutations(map => {
       map.set('in_reply_to', null);
+      if (defaultContentType) map.set('content_type', defaultContentType);
       map.set('text', '');
       map.set('spoiler', false);
       map.set('spoiler_text', '');
index 62588eeaaf74f9449700cc1823c189a300143666..99d8a4dbcab6e4f0860d261babecd0fb30058a38 100644 (file)
@@ -27,5 +27,6 @@ export const invitesEnabled = getMeta('invites_enabled');
 export const version = getMeta('version');
 export const mascot = getMeta('mascot');
 export const isStaff = getMeta('is_staff');
+export const defaultContentType = getMeta('default_content_type');
 
 export default initialState;
index 850169af82a7ef3b718bdc1d794cfab18f601b7d..d74e56ebc8f3bb8f474bac09102abb673f096bbe 100644 (file)
@@ -47,6 +47,7 @@ class InitialStateSerializer < ActiveModel::Serializer
       store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers
       store[:reduce_motion]   = object.current_account.user.setting_reduce_motion
       store[:is_staff]        = object.current_account.user.staff?
+      store[:default_content_type] = object.current_account.user.setting_default_content_type
     end
 
     store