]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] When sending a toot, ensure a CW is only set if the CW field is visible
authorThibaut Girka <thib@sitedethib.com>
Sun, 30 Jun 2019 09:09:54 +0000 (11:09 +0200)
committerThibaut Girka <thib@sitedethib.com>
Sun, 30 Jun 2019 12:35:03 +0000 (14:35 +0200)
Partial port of ccc7fe3e1d04c7cabad916e4e57c7739743d5c91 to glitch-soc

It doesn't ensure the field isn't changed, just that it isn't submitted if
the field isn't visible. Ensuring the field isn't changed would require
reworking the “always show CW field” feature.

app/javascript/flavours/glitch/actions/compose.js

index 69cc6827f46b94e75603e233b368b0a9da1813bc..2312bae634d5033d0fa36bb08c21ea3f15b4b2d1 100644 (file)
@@ -138,7 +138,8 @@ export function submitCompose(routerHistory) {
   return function (dispatch, getState) {
     let status = getState().getIn(['compose', 'text'], '');
     let media  = getState().getIn(['compose', 'media_attachments']);
-    let spoilerText = getState().getIn(['compose', 'spoiler_text'], '');
+    const spoilers = getState().getIn(['compose', 'spoiler']) || getState().getIn(['local_settings', 'always_show_spoilers_field']);
+    let spoilerText = spoilers ? getState().getIn(['compose', 'spoiler_text'], '') : '';
 
     if ((!status || !status.length) && media.size === 0) {
       return;