Filter updates from the server

We don't want $:/StoryList etc.
This commit is contained in:
Jeremy Ruston 2024-03-26 17:16:14 +00:00
parent baee0bb301
commit f2947e73b3
2 changed files with 11 additions and 3 deletions

View File

@ -0,0 +1,2 @@
title: $:/config/multiwikiclient/incoming-updates-filter
text: [all[]] -[[$:/isEncrypted]] -[prefix[$:/temp/]] -[prefix[$:/status/]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[[$:/library/sjcl.js]] -[[$:/core]] -[[$:/StoryList]] -[[$:/HistoryList]]

View File

@ -16,7 +16,8 @@ var CONFIG_HOST_TIDDLER = "$:/config/multiwikiclient/host",
DEFAULT_HOST_TIDDLER = "$protocol$//$host$/",
BAG_STATE_TIDDLER = "$:/state/multiwikiclient/tiddlers/bag",
REVISION_STATE_TIDDLER = "$:/state/multiwikiclient/tiddlers/revision",
CONNECTION_STATE_TIDDLER = "$:/state/multiwikiclient/connection";
CONNECTION_STATE_TIDDLER = "$:/state/multiwikiclient/connection",
INCOMING_UPDATES_FILTER_TIDDLER = "$:/config/multiwikiclient/incoming-updates-filter";
var SERVER_NOT_CONNECTED = "NOT CONNECTED",
SERVER_CONNECTING_SSE = "CONNECTING SSE",
@ -32,6 +33,8 @@ function MultiWikiClientAdaptor(options) {
this.isLoggedIn = false;
this.isReadOnly = false;
this.logoutIsAvailable = true;
// Compile the dirty tiddler filter
this.incomingUpdatesFilterFn = this.wiki.compileFilter(this.wiki.getTiddlerText(INCOMING_UPDATES_FILTER_TIDDLER));
this.setUpdateConnectionStatus(SERVER_NOT_CONNECTED);
}
@ -190,8 +193,11 @@ MultiWikiClientAdaptor.prototype.connectServerStream = function(options) {
options.syncer.wiki.deleteTiddler(data.title);
options.syncer.processTaskQueue();
} else {
self.setTiddlerInfo(data.title,data.tiddler_id,data.bag_name);
options.syncer.storeTiddler(data.tiddler);
var result = self.incomingUpdatesFilterFn.call(self.wiki,self.wiki.makeTiddlerIterator([data.title]));
if(result.length > 0) {
self.setTiddlerInfo(data.title,data.tiddler_id,data.bag_name);
options.syncer.storeTiddler(data.tiddler);
}
}
}
});