diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -82,29 +82,30 @@ return tinycolor(`#${color}`).isDark(); } -const selectedThreadColors = [ - 'B8753D', - 'C85000', - 'AA4B4B', - '4B87AA', - '648CAA', - '57697F', - '6D49AB', - '00A591', - '008F83', - '575757', -]; +const selectedThreadColors = { + 'B8753D': 1, + 'C85000': 2, + 'AA4B4B': 3, + '4B87AA': 4, + '648CAA': 5, + '57697F': 6, + '6D49AB': 7, + '00A591': 8, + '008F83': 9, + '575757': 10, +}; +export type SelectedThreadColors = $Keys; function generateRandomColor(): string { - return selectedThreadColors[ - Math.floor(Math.random() * selectedThreadColors.length) - ]; + const potentialColors = Object.keys(selectedThreadColors); + return potentialColors[Math.floor(Math.random() * potentialColors.length)]; } function generatePendingThreadColor(userIDs: $ReadOnlyArray): string { + const potentialColors = Object.keys(selectedThreadColors); const ids = [...userIDs].sort().join('#'); - const colorIdx = stringHash(ids) % selectedThreadColors.length; - return selectedThreadColors[colorIdx]; + const colorIdx = stringHash(ids) % potentialColors.length; + return potentialColors[colorIdx]; } function threadHasPermission(