Make use of http.cache module on instance_emojis
This commit is contained in:
parent
6980381ad5
commit
1d4c03eaf4
|
@ -207,10 +207,9 @@ app.emoji = {
|
|||
return value;
|
||||
},
|
||||
get: function(name) {
|
||||
var emojis = app.storage.get('emojis_cache');
|
||||
if (emojis === undefined) return null;
|
||||
emojis = JSON.parse(emojis);
|
||||
if (emojis[name] === undefined) return null;
|
||||
var emojis = http.cache.get('instance_emojis');
|
||||
if (emojis === undefined ||
|
||||
emojis[name] === undefined) return null;
|
||||
return emojis[name].url;
|
||||
},
|
||||
}
|
||||
|
@ -244,14 +243,10 @@ window.onload = function(e) {
|
|||
scriptPageHandler('pages.chat', { exact: 'chat' });
|
||||
}
|
||||
|
||||
const ts = new Date().getTime();
|
||||
const ts2 = parseInt(app.storage.get('emojis_cache_ts'));
|
||||
const diff = isNaN(ts2) ? -1 : ((ts - ts2) / 1000);
|
||||
if (diff === -1 || diff >= (30 * 60)) {
|
||||
app.storage.del('emojis_cache');
|
||||
if (http.cache.expired('instance_emojis', 30*60)) {
|
||||
http.cache.del('instance_emojis');
|
||||
http.get('/api/v1/instance/emojis', {}, function(data) {
|
||||
app.storage.set('emojis_cache', data);
|
||||
app.storage.set('emojis_cache_ts', ts);
|
||||
http.cache.set('instance_emojis', data);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ app.pages.meet = {
|
|||
app.pages.meet.data = json;
|
||||
app.template.loadMany(['meet.item','meet.actions'], async function(_) {
|
||||
await waitUntil(function() {
|
||||
return app.storage.get('emojis_cache') !== undefined;
|
||||
return http.cache.get('instance_emojis') !== undefined;
|
||||
}, 3);
|
||||
app.pages.meet.paint(json);
|
||||
app.pages.meet.paintInterval();
|
||||
|
|
Loading…
Reference in New Issue