diff options
author | ThibG <thib@sitedethib.com> | 2018-05-16 20:17:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-16 20:17:08 +0200 |
commit | 80aad16e1035a72fec1af56aaac458a35e1f02c5 (patch) | |
tree | 3553dbe64377e08ca4ed2a2db62a487472bf8405 /app/javascript/flavours/glitch/reducers/compose.js | |
parent | 9712d59dda848a7bc7fd9edb814c16717aa9ba6d (diff) | |
parent | 784712791da8c7d21afa62a3bf6a8fdac8c27a80 (diff) |
Merge pull request #405 from ThibG/glitch-soc/features/dm-from-menu
[Glitch] Feature: Direct message from menu
Diffstat (limited to 'app/javascript/flavours/glitch/reducers/compose.js')
-rw-r--r-- | app/javascript/flavours/glitch/reducers/compose.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 8973c7713..f79fa63d2 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -5,6 +5,7 @@ import { COMPOSE_CYCLE_ELEFRIEND, COMPOSE_REPLY, COMPOSE_REPLY_CANCEL, + COMPOSE_DIRECT, COMPOSE_MENTION, COMPOSE_SUBMIT_REQUEST, COMPOSE_SUBMIT_SUCCESS, @@ -321,10 +322,18 @@ export default function compose(state = initialState, action) { case COMPOSE_UPLOAD_PROGRESS: return state.set('progress', Math.round((action.loaded / action.total) * 100)); case COMPOSE_MENTION: - return state - .update('text', text => `${text}@${action.account.get('acct')} `) - .set('focusDate', new Date()) - .set('idempotencyKey', uuid()); + return state.withMutations(map => { + map.update('text', text => [text.trim(), `@${action.account.get('acct')} `].filter((str) => str.length !== 0).join(' ')); + map.set('focusDate', new Date()); + map.set('idempotencyKey', uuid()); + }); + case COMPOSE_DIRECT: + return state.withMutations(map => { + map.update('text', text => [text.trim(), `@${action.account.get('acct')} `].filter((str) => str.length !== 0).join(' ')); + map.set('privacy', 'direct'); + map.set('focusDate', new Date()); + map.set('idempotencyKey', uuid()); + }); case COMPOSE_SUGGESTIONS_CLEAR: return state.update('suggestions', ImmutableList(), list => list.clear()).set('suggestion_token', null); case COMPOSE_SUGGESTIONS_READY: |