Reduce emojis's set update cycle
Based on this suggestion from @leipert we could reduce emojis' update cycle to be 2 vs 3 iterations (milestones).
I think as a follow-up we should change the frontend code to work like this:
const EMOJI_VERSIONS = ['2', '1'];
async function loadEmojiByVersion(version) {
if (
isLocalStorageAvailable &&
window.localStorage.getItem('gl-emoji-map-version') === version &&
window.localStorage.getItem('gl-emoji-map')
) {
return JSON.parse(window.localStorage.getItem('gl-emoji-map'));
}
// We load the JSON file direct from the server
// because it can't be loaded from a CDN due to
// cross domain problems with JSON
const { data } = await axios.get(
`${gon.relative_url_root || ''}/-/emojis/${version}/emojis.json`,
);
window.localStorage.setItem('gl-emoji-map-version', version);
window.localStorage.setItem('gl-emoji-map', JSON.stringify(data));
return data;
}
async function loadEmoji() {
for(const version of EMOJI_VERSIONS){
try{
const emoji = await loadEmojiByVersion(version);
return emoji;
} catch(){
}
}
throw new Error('Could not load any emoji')
}
That would allow us to reduce the implementation of this from:
- Milestone M => Add emoji assets
- Milestone M+1 => Bump emoji version
- Milestone M+2 => Remove old emoji version
to
- Milestone M => Add emoji assets and add new emoji version
- Milestone M+1 => Remove old emoji version
Furthermore, we can drop
EMOJI_VERSION
andemoji_public_absolute_path
from the ruby code because it is only used in the rake tasklib/tasks/tanuki_emoji.rake