Removed the limit=12, it seems the extra paramater was causing issues

with calls to /timelines/home
This commit is contained in:
Mark Washeim 2023-01-03 14:13:23 +01:00
parent 3bb76d7121
commit bd91ee5611
2 changed files with 24 additions and 40 deletions

View file

@ -15,6 +15,7 @@ WorkerScript.onMessage = function(msg) {
console.log("Conf > " + JSON.stringify(msg.conf)) console.log("Conf > " + JSON.stringify(msg.conf))
console.log("Params > " + JSON.stringify(msg.params)) console.log("Params > " + JSON.stringify(msg.params))
*/ */
// this is not elegant. it's max_id and ids from MyList // this is not elegant. it's max_id and ids from MyList
if (msg.params[1]) { if (msg.params[1]) {
if ( msg.params[0]["name"] === "max_id" ) { if ( msg.params[0]["name"] === "max_id" ) {
@ -54,6 +55,7 @@ WorkerScript.onMessage = function(msg) {
/** POST statuses */ /** POST statuses */
var API = mastodonAPI({ instance: msg.conf.instance, api_user_token: msg.conf.api_user_token}); var API = mastodonAPI({ instance: msg.conf.instance, api_user_token: msg.conf.api_user_token});
if (msg.method === "POST"){ if (msg.method === "POST"){
API.post(msg.action, msg.params, function(data) { API.post(msg.action, msg.params, function(data) {
if (msg.bgAction){ if (msg.bgAction){
@ -79,9 +81,9 @@ WorkerScript.onMessage = function(msg) {
} }
API.get(msg.action, msg.params, function(data) { API.get(msg.action, msg.params, function(data) {
var items = [];
//console.log(msg.ids) var items = [];
//console.log(data)
for (var i in data) { for (var i in data) {
var item; var item;
@ -146,9 +148,14 @@ WorkerScript.onMessage = function(msg) {
if(msg.model && items.length) { if(msg.model && items.length) {
addDataToModel(msg.model, msg.mode, items) addDataToModel(msg.model, msg.mode, items)
} else {
// for some reason, home chokes.
console.log( "items.length = " + items.length)
} }
/*if(msg.action === "notifications") /*if(msg.action === "notifications")
orderNotifications(items)*/ orderNotifications(items)*/
console.log("Get em all?") console.log("Get em all?")
WorkerScript.sendMessage({ 'updatedAll': true}) WorkerScript.sendMessage({ 'updatedAll': true})
}); });
@ -160,25 +167,25 @@ function addDataToModel (model, mode, items) {
var length = items.length; var length = items.length;
console.log("Fetched > " +length + " in " + mode) console.log("Fetched > " +length + " in " + mode)
console.log("ids > " + knownIds.length )
var i var i
if (mode === "append") { if (mode === "append") {
model.append(items)
/*
for(i = 0; i <= length-1; i++) { for(i = 0; i <= length-1; i++) {
if ( knownIds.indexOf( items[i]["id"]) === -1) { if ( knownIds.indexOf( items[i]["id"]) === -1) {
if ( items[i]["id"] < max_id ) {
model.append(items[i]) model.append(items[i])
} else { } else {
console.log("max: " + max_id + " i: " + items[i]["id"] + " known: " + knownIds[knownIds.length-1]) console.log("nope: " + items[i]["id"] )
} }
} }
}
*/ //model.append(items)
} else if (mode === "prepend") { } else if (mode === "prepend") {
for(i = length-1; i >= 0 ; i--) { for(i = length-1; i >= 0 ; i--) {
if ( knownIds.indexOf( items[i]["id"]) === -1) {
model.insert(0,items[i]) model.insert(0,items[i])
} /*if ( knownIds.indexOf( items[i]["id"]) === -1) {
model.insert(0,items[i])
}*/
} }
} }
model.sync() model.sync()

View file

@ -7,7 +7,7 @@ import "."
SilicaListView { SilicaListView {
id: myList id: myList
property bool debug: false property bool debug: true
property string type property string type
property string title property string title
property string description property string description
@ -78,12 +78,6 @@ SilicaListView {
pageStack.push(Qt.resolvedUrl("../SettingsPage.qml"), {}) pageStack.push(Qt.resolvedUrl("../SettingsPage.qml"), {})
} }
} }
MenuItem {
text: qsTr("Clear")
onClicked: {
clearLast()
}
}
MenuItem { MenuItem {
text: qsTr("New Toot") text: qsTr("New Toot")
visible: !profilePage visible: !profilePage
@ -173,11 +167,10 @@ SilicaListView {
id: worker id: worker
source: "../../lib/Worker.js" source: "../../lib/Worker.js"
onMessage: { onMessage: {
//if (debug) console.log("worker says")
//if (debug) console.log(JSON.stringify(messageObject))
if (messageObject.error){ if (messageObject.error){
if (debug) console.log(JSON.stringify(messageObject)) if (debug) console.log(JSON.stringify(messageObject))
} else { } else {
if (debug) console.log(JSON.stringify(messageObject))
loadStarted = false loadStarted = false
} }
@ -188,7 +181,7 @@ SilicaListView {
// should be resolved within loadData() // should be resolved within loadData()
if (messageObject.updatedAll){ if (messageObject.updatedAll){
if (debug) console.log("Got em all.") if (debug) console.log("Got em all.")
if (model.count > 20) deDouble() if (model.count > 12) deDouble()
loadStarted = false 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 /* Principle load function, uses websocket's worker.js
* *
*/ */