mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-05-02 01:57:12 +00:00
More efficient syncing
Thank you @PotOfCoffee2Go I ended up taking some of your code from #8101 to get this up and running. There's still some stuff missing (like the tests!) but it gets things moving.
This commit is contained in:
@@ -20,17 +20,14 @@ exports.handler = function(request,response,state) {
|
||||
// Get the parameters
|
||||
var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]);
|
||||
if(recipe_name) {
|
||||
// Get the tiddlers in the recipe
|
||||
var recipeTiddlers = $tw.mws.store.getRecipeTiddlers(recipe_name);
|
||||
// Get a skinny version of each tiddler
|
||||
var tiddlers = [];
|
||||
$tw.utils.each(recipeTiddlers,function(recipeTiddlerInfo) {
|
||||
var tiddlerInfo = $tw.mws.store.getRecipeTiddler(recipeTiddlerInfo.title,recipe_name);
|
||||
tiddlers.push(Object.assign({},tiddlerInfo.tiddler,{text: undefined}));
|
||||
// Get the tiddlers in the recipe, optionally since the specified last known tiddler_id
|
||||
var recipeTiddlers = $tw.mws.store.getRecipeTiddlers(recipe_name,{
|
||||
last_known_tiddler_id: state.queryParameters.last_known_tiddler_id
|
||||
});
|
||||
var text = JSON.stringify(tiddlers);
|
||||
state.sendResponse(200,{"Content-Type": "application/json"},text,"utf8");
|
||||
return;
|
||||
if(recipeTiddlers) {
|
||||
state.sendResponse(200,{"Content-Type": "application/json"},JSON.stringify(recipeTiddlers),"utf8");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Fail if something went wrong
|
||||
response.writeHead(404);
|
||||
|
||||
@@ -77,6 +77,10 @@ exports.handler = function(request,response,state) {
|
||||
title: "$:/config/multiwikiclient/recipe",
|
||||
text: recipe_name
|
||||
});
|
||||
writeTiddler({
|
||||
title: "$:/state/multiwikiclient/recipe/last_tiddler_id",
|
||||
text: $tw.mws.store.getRecipeLastTiddlerId(recipe_name).toString()
|
||||
});
|
||||
response.write(template.substring(markerPos + marker.length))
|
||||
// Finish response
|
||||
response.end();
|
||||
|
||||
Reference in New Issue
Block a user