]> cat aescling's git repositories - mastodon.git/commitdiff
Refactor privacyPrefence() to use priority list (#7945)
authorMaciek Baron <thebezet@gmail.com>
Wed, 4 Jul 2018 15:35:35 +0000 (16:35 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 4 Jul 2018 15:35:35 +0000 (17:35 +0200)
app/javascript/mastodon/reducers/compose.js

index 8524ddb8e0562d2c73b3697857c1ae6c1183d7b0..552f659c9276e7714ca60a78b8146313b1ef7e1f 100644 (file)
@@ -151,15 +151,8 @@ const insertEmoji = (state, position, emojiData, needsSpace) => {
 };
 
 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) => {