about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/util
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-05-15 17:30:40 +0200
committerGitHub <noreply@github.com>2022-05-15 17:30:40 +0200
commitdc350be6f5a9f59385e6fbc7a06b5b9c0d57aec8 (patch)
treeef7ebcaf1937165a14b2c53264f1f4ffb224c1d9 /app/javascript/flavours/glitch/util
parentaa08399e6f4ff35a7ece05ebbeca4b9771c97927 (diff)
Use upstream's settings for CW auto-expand and column swiping (#1770)
* Use Mastodon server-side settings for automatically expanding toots with CWs

* Add modal warning about settings changes

* Use Mastodon server-side settings for disabling swiping
Diffstat (limited to 'app/javascript/flavours/glitch/util')
-rw-r--r--app/javascript/flavours/glitch/util/backend_links.js9
-rw-r--r--app/javascript/flavours/glitch/util/content_warning.js4
-rw-r--r--app/javascript/flavours/glitch/util/initial_state.js3
3 files changed, 14 insertions, 2 deletions
diff --git a/app/javascript/flavours/glitch/util/backend_links.js b/app/javascript/flavours/glitch/util/backend_links.js
index 2e5111a7f..5b2dd8dbf 100644
--- a/app/javascript/flavours/glitch/util/backend_links.js
+++ b/app/javascript/flavours/glitch/util/backend_links.js
@@ -7,3 +7,12 @@ export const statusAdminLink = (account_id, status_id) => `/admin/accounts/${acc
 export const filterEditLink = (id) => `/filters/${id}/edit`;
 export const relationshipsLink = '/relationships';
 export const securityLink = '/auth/edit';
+export const preferenceLink = (setting_name) => {
+  switch (setting_name) {
+  case 'user_setting_expand_spoilers':
+  case 'user_setting_disable_swiping':
+    return `/settings/preferences/appearance#${setting_name}`;
+  default:
+    return preferencesLink;
+  }
+};
diff --git a/app/javascript/flavours/glitch/util/content_warning.js b/app/javascript/flavours/glitch/util/content_warning.js
index 5e874a49c..baeb97881 100644
--- a/app/javascript/flavours/glitch/util/content_warning.js
+++ b/app/javascript/flavours/glitch/util/content_warning.js
@@ -1,5 +1,7 @@
+import { expandSpoilers } from 'flavours/glitch/util/initial_state';
+
 export function autoUnfoldCW (settings, status) {
-  if (!settings.getIn(['content_warnings', 'auto_unfold'])) {
+  if (!expandSpoilers) {
     return false;
   }
 
diff --git a/app/javascript/flavours/glitch/util/initial_state.js b/app/javascript/flavours/glitch/util/initial_state.js
index 7154e020b..5cbf8f6c3 100644
--- a/app/javascript/flavours/glitch/util/initial_state.js
+++ b/app/javascript/flavours/glitch/util/initial_state.js
@@ -13,8 +13,8 @@ const getMeta = (prop) => initialState && initialState.meta && initialState.meta
 
 export const reduceMotion = getMeta('reduce_motion');
 export const autoPlayGif = getMeta('auto_play_gif');
-export const displaySensitiveMedia = getMeta('display_sensitive_media');
 export const displayMedia = getMeta('display_media') || (getMeta('display_sensitive_media') ? 'show_all' : 'default');
+export const expandSpoilers = getMeta('expand_spoilers');
 export const unfollowModal = getMeta('unfollow_modal');
 export const boostModal = getMeta('boost_modal');
 export const favouriteModal = getMeta('favourite_modal');
@@ -37,5 +37,6 @@ export const useBlurhash = getMeta('use_blurhash');
 export const usePendingItems = getMeta('use_pending_items');
 export const useSystemEmojiFont = getMeta('system_emoji_font');
 export const showTrends = getMeta('trends');
+export const disableSwiping = getMeta('disable_swiping');
 
 export default initialState;