Skip to content

Commit

Permalink
update caches if tiddler with tag has been deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
pmario committed Nov 27, 2023
1 parent 9897ff6 commit 3c51440
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions core/modules/indexers/tag-indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,16 @@ TagIndexer.prototype.update = function(updateDescriptor) {
var newTid = updateDescriptor.new.tiddler;
var oldTid = updateDescriptor.old.tiddler;
var noOldTid = oldTid === undefined;
var noNewTid = newTid === undefined;

// Index should be kept when there is no new tiddler
if (noNewTid) {
return; // early
} // -> or
// a) new tiddler has no tags && no old tiddler -> or
// b) new tiddler has no tags && old tiddler has no tags
// b) new tiddler has no tags && old tiddler has no tags -> return early!
var a=((newTid && newTid.fields && newTid.fields.tags === undefined) && noOldTid),
b=((newTid && newTid.fields && newTid.fields.tags === undefined) && (oldTid && oldTid.fields && oldTid.fields.tags === undefined));

if( a || b ) {
return;
return; // early
}

$tw.utils.each(this.subIndexers,function(subIndexer) {
subIndexer.update(updateDescriptor);
});
Expand All @@ -73,6 +69,9 @@ TagSubIndexer.prototype.addIndexMethod = function() {
TagSubIndexer.prototype.rebuild = function() {
var self = this;
// Hashmap by tag of array of {isSorted:, titles:[]}

const t0 = $tw.utils.timer();

this.index = Object.create(null);
// Add all the tags
this.indexer.wiki[this.iteratorMethod](function(tiddler,title) {
Expand All @@ -84,6 +83,9 @@ TagSubIndexer.prototype.rebuild = function() {
}
});
});

console.log("--------------- ", $tw.utils.timer(t0), this.iteratorMethod);

};

TagSubIndexer.prototype.update = function(updateDescriptor) {
Expand Down

0 comments on commit 3c51440

Please sign in to comment.