diff options
author | ThibG <thib@sitedethib.com> | 2019-07-07 22:26:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-07 22:26:10 +0200 |
commit | fce885f271f8651702d606406e21677280071e40 (patch) | |
tree | 2ebb76c77088edf0662ef333523ef0f0a03b6c4e /app/javascript/flavours/glitch/reducers | |
parent | e5f4d83e60305e2f502f18f507ad79d8fbccfe77 (diff) | |
parent | 5ff9970c8d4acfb69b4696a3b5ce8e2a9580e370 (diff) |
Merge pull request #1152 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/flavours/glitch/reducers')
-rw-r--r-- | app/javascript/flavours/glitch/reducers/compose.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 36dfb8f15..a47b8b7bd 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -275,6 +275,12 @@ const expandMentions = status => { return fragment.innerHTML; }; +const expiresInFromExpiresAt = expires_at => { + if (!expires_at) return 24 * 3600; + const delta = (new Date(expires_at).getTime() - Date.now()) / 1000; + return [300, 1800, 3600, 21600, 86400, 259200, 604800].find(expires_in => expires_in >= delta) || 24 * 3600; +}; + export default function compose(state = initialState, action) { switch(action.type) { case STORE_HYDRATE: @@ -456,7 +462,7 @@ export default function compose(state = initialState, action) { map.set('poll', ImmutableMap({ options: action.status.getIn(['poll', 'options']).map(x => x.get('title')), multiple: action.status.getIn(['poll', 'multiple']), - expires_in: 24 * 3600, + expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])), })); } }); |