From cd05378b594184d3b736b6ef6ef1c6e3d159db21 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Thu, 12 Jul 2018 11:30:47 +0200 Subject: [PATCH] [Glitch] Refactor privacyPrefence() to use priority list Port f2d9a3c239bcab5fcbede22549b67bfd841a3880 to glitch-soc --- app/javascript/flavours/glitch/reducers/compose.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index a7ce71676c3..9c2a501e144 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -207,15 +207,8 @@ const insertEmoji = (state, position, emojiData) => { }; const privacyPreference = (a, b) => { - if (a === 'direct' || b === 'direct') { - return 'direct'; - } else if (a === 'private' || b === 'private') { - return 'private'; - } else if (a === 'unlisted' || b === 'unlisted') { - return 'unlisted'; - } else { - return 'public'; - } + const order = ['public', 'unlisted', 'private', 'direct']; + return order[Math.max(order.indexOf(a), order.indexOf(b), 0)]; }; const hydrate = (state, hydratedState) => {