From 7dfae9639455c1b60d6e953c4b242af1b664284f Mon Sep 17 00:00:00 2001 From: Mark Washeim Date: Wed, 18 Jan 2023 09:20:27 +0100 Subject: [PATCH 1/2] [Issue]: # 26. timelines/home on append uses the link header for min/max id --- harbour-tooterb.pro.user | 2 +- qml/lib/Worker.js | 31 ++++++++++++++----------------- qml/pages/components/MyList.qml | 9 +++++++-- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/harbour-tooterb.pro.user b/harbour-tooterb.pro.user index b79aa86..41aebd6 100644 --- a/harbour-tooterb.pro.user +++ b/harbour-tooterb.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/qml/lib/Worker.js b/qml/lib/Worker.js index c906c69..4a162bb 100644 --- a/qml/lib/Worker.js +++ b/qml/lib/Worker.js @@ -8,27 +8,24 @@ var max_id ; var since_id; WorkerScript.onMessage = function(msg) { -/* - console.log("Action > " + msg.action) - console.log("Model > " + msg.model) - console.log("Mode > " + msg.mode) - console.log("Conf > " + JSON.stringify(msg.conf)) - console.log("Params > " + JSON.stringify(msg.params)) -*/ + + if (debug) console.log("Action > " + msg.action) + if (debug) console.log("Mode > " + msg.mode) // this is not elegant. it's max_id and ids from MyList - - if (msg.params[1]) { + // we should always get max_id on append + if (msg.mode === "append") { if ( msg.params[0]["name"] === "max_id" ) { max_id = msg.params[0]["data"] - } else { - since_id = msg.params[0]["data"] - } - // we don't want to pass it onto the backend - if ( msg.params[1]["name"] === "ids" ) { - knownIds = msg.params[1]["data"] - msg.params.pop() } + } else if ( msg.mode === "prepend" && msg.params[0]) { + + // prepend could be min_id or since_id + since_id = msg.params[0]["data"] + + } + // ids are always the last param + if (msg.params[2]) { if ( msg.params[2]["name"] === "ids" ) { knownIds = msg.params[2]["data"] msg.params.pop() @@ -65,7 +62,7 @@ WorkerScript.onMessage = function(msg) { * this falls through and continues for GET */ - if (msg.action === "bookmarks"){ + if (msg.action === "bookmarks" || ( msg.action === "timelines/home" && msg.mode === "append") ){ API.getLink(msg.action, msg.params, function(data) { if (debug) console.log(JSON.stringify(data)) WorkerScript.sendMessage({ 'LinkHeader': data }) diff --git a/qml/pages/components/MyList.qml b/qml/pages/components/MyList.qml index 12df57b..4f77ec2 100644 --- a/qml/pages/components/MyList.qml +++ b/qml/pages/components/MyList.qml @@ -7,7 +7,7 @@ import "." SilicaListView { id: myList - property bool debug: false + property bool debug: true property string type property string title property string description @@ -350,11 +350,16 @@ SilicaListView { } } - //if (debug) console.log(JSON.stringify(uniqueIds)) + // to keep the number of params the same for all requests + // always set local + if(title === "Local") { type = "timelines/public" p.push({name:'local', data: "true"}) + } else { + p.push({name:'local', data: "false"}) } + // we push the ids via params which we remove in the WorkerScript if (model.count) { p.push({name:'ids', data: uniqueIds}) From 32bde3b34228dfc94334db1ff2352269c92bfa0a Mon Sep 17 00:00:00 2001 From: Mark Washeim Date: Wed, 18 Jan 2023 11:03:53 +0100 Subject: [PATCH 2/2] [Fix] search for tags and persons added header call for max/min and prepend on first call. --- qml/lib/Worker.js | 6 ++++-- qml/pages/MainPage.qml | 32 ++++++++------------------------ qml/pages/components/MyList.qml | 2 +- rpm/harbour-tooterb.spec | 2 +- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/qml/lib/Worker.js b/qml/lib/Worker.js index 4a162bb..12a225b 100644 --- a/qml/lib/Worker.js +++ b/qml/lib/Worker.js @@ -1,6 +1,6 @@ Qt.include("Mastodon.js") -var debug = true; +var debug = false; var loadImages = true; // used to dedupe on append/insert var knownIds = []; @@ -62,7 +62,9 @@ WorkerScript.onMessage = function(msg) { * this falls through and continues for GET */ - if (msg.action === "bookmarks" || ( msg.action === "timelines/home" && msg.mode === "append") ){ + if (msg.action === "bookmarks" || + ( msg.action === "timelines/home" && msg.mode === "append") || + ( msg.action.indexOf("timelines/tag/") !== -1 ) ){ API.getLink(msg.action, msg.params, function(data) { if (debug) console.log(JSON.stringify(data)) WorkerScript.sendMessage({ 'LinkHeader': data }) diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index c155e69..9db752a 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -158,19 +158,11 @@ Page { delegate: VisualContainer Component.onCompleted: { view.type = "timelines/tag/"+tlSearch.search.substring(1) - var ids = [] - view.params = [] - view.params.push({name: 'limit', data: "20" }); - /* we push the ids via params which we remove in the WorkerScript - * see: MyList:loadData() and should move */ if (mdl.count) { - for(var i = 0 ; i < mdl.count ; i++) { - ids.push(mdl.get(i).id) - //if (debug) console.log(model.get(i).id) - } - view.params.push({name: 'ids', data: ids }); + view.loadData("append") + } else { + view.loadData("prepend") } - view.loadData("append") } } } @@ -241,20 +233,12 @@ Page { delegate: VisualContainer Component.onCompleted: { - var ids = [] - view3.params = [] - view3.params.push({name: 'limit', data: "20" }); - /* we push the ids via params which we remove in the WorkerScript - * see: MyList:loadData() and should move */ - if (mdl.count) { - for(var i = 0 ; i < mdl.count ; i++) { - ids.push(mdl.get(i).id) - //if (debug) console.log(model.get(i).id) - } - view3.params.push({name: 'ids', data: ids }); - } view3.type = "timelines/tag/"+tlSearch.search - view3.loadData("prepend") + if (mdl.count) { + view3.loadData("append") + } else { + view3.loadData("prepend") + } } } } diff --git a/qml/pages/components/MyList.qml b/qml/pages/components/MyList.qml index 4f77ec2..9180729 100644 --- a/qml/pages/components/MyList.qml +++ b/qml/pages/components/MyList.qml @@ -7,7 +7,7 @@ import "." SilicaListView { id: myList - property bool debug: true + property bool debug: false property string type property string title property string description diff --git a/rpm/harbour-tooterb.spec b/rpm/harbour-tooterb.spec index 93a27ea..5f25e30 100644 --- a/rpm/harbour-tooterb.spec +++ b/rpm/harbour-tooterb.spec @@ -13,7 +13,7 @@ Name: harbour-tooterb %{!?qtc_make:%define qtc_make make} %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: Tooter β -Version: 1.1.3 +Version: 1.1.4 Release: 1 Group: Qt/Qt License: GPLv3