From bd91ee56113917a8885bbeb935c22ccc6dbfe7ca Mon Sep 17 00:00:00 2001 From: Mark Washeim Date: Tue, 3 Jan 2023 14:13:23 +0100 Subject: [PATCH] Removed the limit=12, it seems the extra paramater was causing issues with calls to /timelines/home --- qml/lib/Worker.js | 35 ++++++++++++++++++++------------- qml/pages/components/MyList.qml | 29 +++------------------------ 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/qml/lib/Worker.js b/qml/lib/Worker.js index c4df622..7878cee 100644 --- a/qml/lib/Worker.js +++ b/qml/lib/Worker.js @@ -15,6 +15,7 @@ WorkerScript.onMessage = function(msg) { console.log("Conf > " + JSON.stringify(msg.conf)) console.log("Params > " + JSON.stringify(msg.params)) */ + // this is not elegant. it's max_id and ids from MyList if (msg.params[1]) { if ( msg.params[0]["name"] === "max_id" ) { @@ -54,6 +55,7 @@ WorkerScript.onMessage = function(msg) { /** POST statuses */ var API = mastodonAPI({ instance: msg.conf.instance, api_user_token: msg.conf.api_user_token}); + if (msg.method === "POST"){ API.post(msg.action, msg.params, function(data) { if (msg.bgAction){ @@ -78,10 +80,10 @@ WorkerScript.onMessage = function(msg) { return; } - API.get(msg.action, msg.params, function(data) { - var items = []; + API.get(msg.action, msg.params, function(data) { - //console.log(msg.ids) + var items = []; + //console.log(data) for (var i in data) { var item; @@ -146,9 +148,14 @@ WorkerScript.onMessage = function(msg) { if(msg.model && items.length) { addDataToModel(msg.model, msg.mode, items) + } else { + // for some reason, home chokes. + console.log( "items.length = " + items.length) } + /*if(msg.action === "notifications") orderNotifications(items)*/ + console.log("Get em all?") WorkerScript.sendMessage({ 'updatedAll': true}) }); @@ -160,25 +167,25 @@ function addDataToModel (model, mode, items) { var length = items.length; console.log("Fetched > " +length + " in " + mode) + console.log("ids > " + knownIds.length ) var i if (mode === "append") { - model.append(items) - /* for(i = 0; i <= length-1; i++) { if ( knownIds.indexOf( items[i]["id"]) === -1) { - if ( items[i]["id"] < max_id ) { - model.append(items[i]) - } else { - console.log("max: " + max_id + " i: " + items[i]["id"] + " known: " + knownIds[knownIds.length-1]) - } - } + model.append(items[i]) + } else { + console.log("nope: " + items[i]["id"] ) + } } - */ + + //model.append(items) + } else if (mode === "prepend") { for(i = length-1; i >= 0 ; i--) { - if ( knownIds.indexOf( items[i]["id"]) === -1) { + model.insert(0,items[i]) + /*if ( knownIds.indexOf( items[i]["id"]) === -1) { model.insert(0,items[i]) - } + }*/ } } model.sync() diff --git a/qml/pages/components/MyList.qml b/qml/pages/components/MyList.qml index fc20bff..d4c75f5 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 @@ -78,12 +78,6 @@ SilicaListView { pageStack.push(Qt.resolvedUrl("../SettingsPage.qml"), {}) } } - MenuItem { - text: qsTr("Clear") - onClicked: { - clearLast() - } - } MenuItem { text: qsTr("New Toot") visible: !profilePage @@ -173,11 +167,10 @@ SilicaListView { id: worker source: "../../lib/Worker.js" onMessage: { - //if (debug) console.log("worker says") - //if (debug) console.log(JSON.stringify(messageObject)) if (messageObject.error){ if (debug) console.log(JSON.stringify(messageObject)) } else { + if (debug) console.log(JSON.stringify(messageObject)) loadStarted = false } @@ -188,7 +181,7 @@ SilicaListView { // should be resolved within loadData() if (messageObject.updatedAll){ if (debug) console.log("Got em all.") - if (model.count > 20) deDouble() + if (model.count > 12) deDouble() loadStarted = false } } @@ -290,22 +283,6 @@ SilicaListView { } - /* utility to clear last, debugging - * - */ - - function clearLast() { - var msg = { - 'action' : "CLEAR", - 'model' : model, - 'conf' : Logic.conf - } - - //if (debug) console.log(JSON.stringify(msg)) - if (model.count) - worker.sendMessage(msg) - } - /* Principle load function, uses websocket's worker.js * */