From 200cd3b5a70f7f1f187dee780858f383260c439a Mon Sep 17 00:00:00 2001 From: ThibG Date: Sun, 17 Mar 2019 03:13:29 +0100 Subject: [Glitch] Save quick filter settings when selecting a different filter Port 7477db7268f2a4c158e5f7683493a728d632f7e2 to glitch-soc --- app/javascript/flavours/glitch/actions/notifications.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/javascript/flavours/glitch/actions') diff --git a/app/javascript/flavours/glitch/actions/notifications.js b/app/javascript/flavours/glitch/actions/notifications.js index dd4f5fd44..57fecf63d 100644 --- a/app/javascript/flavours/glitch/actions/notifications.js +++ b/app/javascript/flavours/glitch/actions/notifications.js @@ -7,6 +7,7 @@ import { importFetchedStatus, importFetchedStatuses, } from './importer'; +import { saveSettings } from './settings'; import { defineMessages } from 'react-intl'; import { List as ImmutableList } from 'immutable'; import { unescapeHTML } from 'flavours/glitch/util/html'; @@ -286,5 +287,6 @@ export function setFilter (filterType) { value: filterType, }); dispatch(expandNotifications()); + dispatch(saveSettings()); }; }; -- cgit From 8b5b686f087f99d1a2b54e0760add8180d77fa7e Mon Sep 17 00:00:00 2001 From: ThibG Date: Wed, 20 Mar 2019 17:29:12 +0100 Subject: [Glitch] Add support for custom emojis in poll options Fixes #956 Port 80f0910e2141b24082b9143266a9a6cf1ef6a516 to glitch-soc --- .../flavours/glitch/actions/importer/normalizer.js | 4 +++- app/javascript/flavours/glitch/components/poll.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'app/javascript/flavours/glitch/actions') diff --git a/app/javascript/flavours/glitch/actions/importer/normalizer.js b/app/javascript/flavours/glitch/actions/importer/normalizer.js index ccd84364e..a8c3fe16a 100644 --- a/app/javascript/flavours/glitch/actions/importer/normalizer.js +++ b/app/javascript/flavours/glitch/actions/importer/normalizer.js @@ -69,9 +69,11 @@ export function normalizeStatus(status, normalOldStatus) { export function normalizePoll(poll) { const normalPoll = { ...poll }; + const emojiMap = makeEmojiMap(normalPoll); + normalPoll.options = poll.options.map(option => ({ ...option, - title_emojified: emojify(escapeTextContentForBrowser(option.title)), + title_emojified: emojify(escapeTextContentForBrowser(option.title), emojiMap), })); return normalPoll; diff --git a/app/javascript/flavours/glitch/components/poll.js b/app/javascript/flavours/glitch/components/poll.js index a1b297ce7..56331cb29 100644 --- a/app/javascript/flavours/glitch/components/poll.js +++ b/app/javascript/flavours/glitch/components/poll.js @@ -44,6 +44,11 @@ const timeRemainingString = (intl, date, now) => { return relativeTime; }; +const makeEmojiMap = record => record.get('emojis').reduce((obj, emoji) => { + obj[`:${emoji.get('shortcode')}:`] = emoji.toJS(); + return obj; +}, {}); + export default @injectIntl class Poll extends ImmutablePureComponent { @@ -99,6 +104,12 @@ class Poll extends ImmutablePureComponent { const active = !!this.state.selected[`${optionIndex}`]; const showResults = poll.get('voted') || poll.get('expired'); + let titleEmojified = option.get('title_emojified'); + if (!titleEmojified) { + const emojiMap = makeEmojiMap(poll); + titleEmojified = emojify(escapeTextContentForBrowser(option.get('title')), emojiMap); + } + return (
  • {showResults && ( @@ -122,7 +133,7 @@ class Poll extends ImmutablePureComponent { {!showResults && } {showResults && {Math.round(percent)}%} - +
  • ); -- cgit