diff options
author | pluralcafe-docker <git@plural.cafe> | 2018-09-03 23:46:14 +0000 |
---|---|---|
committer | pluralcafe-docker <git@plural.cafe> | 2018-09-03 23:46:14 +0000 |
commit | 1e6f96168146b89df9940d2b77963a7a30ba84cb (patch) | |
tree | 06e1a473f10ff6f1c3743e1ff729f95be6d134e5 /app/javascript/flavours/glitch/util | |
parent | cc7437e25597e24b9a5f06f7991861506d9abe5c (diff) | |
parent | 40d04a3209871b9803b27d01f935ab401bf3539f (diff) |
Merge branch 'glitch'
Diffstat (limited to 'app/javascript/flavours/glitch/util')
-rw-r--r-- | app/javascript/flavours/glitch/util/content_warning.js | 19 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/util/emoji/index.js | 4 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/util/initial_state.js | 2 |
3 files changed, 25 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/util/content_warning.js b/app/javascript/flavours/glitch/util/content_warning.js new file mode 100644 index 000000000..29e221c8e --- /dev/null +++ b/app/javascript/flavours/glitch/util/content_warning.js @@ -0,0 +1,19 @@ +export function autoUnfoldCW (settings, status) { + if (!settings.getIn(['content_warnings', 'auto_unfold'])) { + return false; + } + + const rawRegex = settings.getIn(['content_warnings', 'filter']); + let regex = null; + + try { + regex = rawRegex && new RegExp(rawRegex.trim(), 'i'); + } catch (e) { + // Bad regex, don't affect filters + } + + if (!(status && regex)) { + return undefined; + } + return !regex.test(status.get('spoiler_text')); +} diff --git a/app/javascript/flavours/glitch/util/emoji/index.js b/app/javascript/flavours/glitch/util/emoji/index.js index c6416db2d..82a1ef89c 100644 --- a/app/javascript/flavours/glitch/util/emoji/index.js +++ b/app/javascript/flavours/glitch/util/emoji/index.js @@ -62,6 +62,10 @@ const emojify = (str, customEmojis = {}) => { const title = shortCode ? `:${shortCode}:` : ''; replacement = `<img draggable="false" class="emojione" alt="${match}" title="${title}" src="${assetHost}/emoji/${filename}.svg" />`; rend = i + match.length; + // If the matched character was followed by VS15 (for selecting text presentation), skip it. + if (str.codePointAt(rend) === 65038) { + rend += 1; + } } rtn += str.slice(0, i) + replacement; str = str.slice(rend); diff --git a/app/javascript/flavours/glitch/util/initial_state.js b/app/javascript/flavours/glitch/util/initial_state.js index 2c4ab9091..fdf004527 100644 --- a/app/javascript/flavours/glitch/util/initial_state.js +++ b/app/javascript/flavours/glitch/util/initial_state.js @@ -19,6 +19,8 @@ export const boostModal = getMeta('boost_modal'); export const favouriteModal = getMeta('favourite_modal'); export const deleteModal = getMeta('delete_modal'); export const me = getMeta('me'); +export const searchEnabled = getMeta('search_enabled'); export const maxChars = (initialState && initialState.max_toot_chars) || 500; +export const isStaff = getMeta('is_staff'); export default initialState; |