Actually prune cached video titles
This commit is contained in:
parent
ca45ed6fe1
commit
f5c9927914
@ -8111,8 +8111,9 @@
|
||||
if (Conf['Comment Expansion']) {
|
||||
ExpandComment.callbacks.push(this.node);
|
||||
}
|
||||
if (Conf['Title Link']) {
|
||||
if (Conf['Link Title']) {
|
||||
$.sync('CachedTitles', Linkify.titleSync);
|
||||
this.clean();
|
||||
}
|
||||
return Post.callbacks.push({
|
||||
name: 'Linkify',
|
||||
@ -8328,6 +8329,26 @@
|
||||
titleSync: function(value) {
|
||||
return Conf['CachedTitles'] = value;
|
||||
},
|
||||
clean: function() {
|
||||
var age, name, pruned, uid, _ref, _ref1;
|
||||
pruned = false;
|
||||
c.log('cleaning');
|
||||
c.log(Object.keys(Conf.CachedTitles).length);
|
||||
_ref = Conf['CachedTitles'];
|
||||
for (uid in _ref) {
|
||||
_ref1 = _ref[uid], name = _ref1[0], age = _ref1[1];
|
||||
if (!(age + $.DAY > Date.now())) {
|
||||
continue;
|
||||
}
|
||||
pruned = true;
|
||||
delete Conf['CachedTitles'][uid];
|
||||
}
|
||||
c.log(Object.keys(Conf.CachedTitles).length);
|
||||
c.log('cleaned');
|
||||
if (pruned) {
|
||||
return $.set('CachedTitles', Conf['CachedTitles']);
|
||||
}
|
||||
},
|
||||
cb: {
|
||||
toggle: function() {
|
||||
var string, _ref;
|
||||
|
||||
@ -8162,8 +8162,9 @@
|
||||
if (Conf['Comment Expansion']) {
|
||||
ExpandComment.callbacks.push(this.node);
|
||||
}
|
||||
if (Conf['Title Link']) {
|
||||
if (Conf['Link Title']) {
|
||||
$.sync('CachedTitles', Linkify.titleSync);
|
||||
this.clean();
|
||||
}
|
||||
return Post.callbacks.push({
|
||||
name: 'Linkify',
|
||||
@ -8379,6 +8380,26 @@
|
||||
titleSync: function(value) {
|
||||
return Conf['CachedTitles'] = value;
|
||||
},
|
||||
clean: function() {
|
||||
var age, name, pruned, uid, _ref, _ref1;
|
||||
pruned = false;
|
||||
c.log('cleaning');
|
||||
c.log(Object.keys(Conf.CachedTitles).length);
|
||||
_ref = Conf['CachedTitles'];
|
||||
for (uid in _ref) {
|
||||
_ref1 = _ref[uid], name = _ref1[0], age = _ref1[1];
|
||||
if (!(age + $.DAY > Date.now())) {
|
||||
continue;
|
||||
}
|
||||
pruned = true;
|
||||
delete Conf['CachedTitles'][uid];
|
||||
}
|
||||
c.log(Object.keys(Conf.CachedTitles).length);
|
||||
c.log('cleaned');
|
||||
if (pruned) {
|
||||
return $.set('CachedTitles', Conf['CachedTitles']);
|
||||
}
|
||||
},
|
||||
cb: {
|
||||
toggle: function() {
|
||||
var string, _ref;
|
||||
|
||||
@ -5,8 +5,9 @@ Linkify =
|
||||
if Conf['Comment Expansion']
|
||||
ExpandComment.callbacks.push @node
|
||||
|
||||
if Conf['Title Link']
|
||||
if Conf['Link Title']
|
||||
$.sync 'CachedTitles', Linkify.titleSync
|
||||
@clean()
|
||||
|
||||
Post.callbacks.push
|
||||
name: 'Linkify'
|
||||
@ -190,7 +191,7 @@ Linkify =
|
||||
embed.dataset.title = title[0]
|
||||
else
|
||||
try
|
||||
$.cache service.api(uid),
|
||||
$.cache service.api(uid),
|
||||
-> title = Linkify.cb.title @, data
|
||||
,
|
||||
responseType: 'json'
|
||||
@ -205,6 +206,13 @@ Linkify =
|
||||
titleSync: (value) ->
|
||||
Conf['CachedTitles'] = value
|
||||
|
||||
clean: ->
|
||||
pruned = false
|
||||
for uid, [name, age] of Conf['CachedTitles'] when age + $.DAY > Date.now()
|
||||
pruned = true
|
||||
delete Conf['CachedTitles'][uid]
|
||||
$.set 'CachedTitles', Conf['CachedTitles'] if pruned
|
||||
|
||||
cb:
|
||||
toggle: ->
|
||||
[string, @textContent] = if $.hasClass @, "embedded"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user