about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/reducers/compose.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-06-15 21:31:08 +0200
committerThibG <thib@sitedethib.com>2018-06-16 15:09:28 +0200
commit26c20a4ec7868753b284670575f28f201a5cef9f (patch)
tree3335c2dee439be101e89d23b27736b0f614a445c /app/javascript/flavours/glitch/reducers/compose.js
parenta01faecfcb9ee3d73ba84bec43536bde0f93d1cf (diff)
[Glitch] Preserve newlines in delete & redraft and desktop notifications
Port c75493755f482d0506884b1f7b7b44e5306a4d8b to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/reducers/compose.js')
-rw-r--r--app/javascript/flavours/glitch/reducers/compose.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js
index da75abbe3..a7ce71676 100644
--- a/app/javascript/flavours/glitch/reducers/compose.js
+++ b/app/javascript/flavours/glitch/reducers/compose.js
@@ -37,6 +37,7 @@ import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrde
 import uuid from 'flavours/glitch/util/uuid';
 import { me } from 'flavours/glitch/util/initial_state';
 import { overwrite } from 'flavours/glitch/util/js_helpers';
+import { unescapeHTML } from 'flavours/glitch/util/html';
 
 const totalElefriends = 3;
 
@@ -229,14 +230,14 @@ const hydrate = (state, hydratedState) => {
 
 const domParser = new DOMParser();
 
-const htmlToText = status => {
+const expandMentions = status => {
   const fragment = domParser.parseFromString(status.get('content'), 'text/html').documentElement;
 
   status.get('mentions').forEach(mention => {
     fragment.querySelector(`a[href="${mention.get('url')}"]`).textContent = `@${mention.get('acct')}`;
   });
 
-  return fragment.textContent;
+  return fragment.innerHTML;
 };
 
 export default function compose(state = initialState, action) {
@@ -381,7 +382,7 @@ export default function compose(state = initialState, action) {
     return state.mergeIn(['doodle'], action.options);
   case REDRAFT:
     return state.withMutations(map => {
-      map.set('text', htmlToText(action.status));
+      map.set('text', unescapeHTML(expandMentions(action.status)));
       map.set('in_reply_to', action.status.get('in_reply_to_id'));
       map.set('privacy', action.status.get('visibility'));
       map.set('media_attachments', action.status.get('media_attachments'));