Reduce calls to api to 12 at a time, instead of 20.
Remove Action local=true string and add it back to params removing duplication, QML/Worker Add checks at prepend to reduce duplicates. Worker.
This commit is contained in:
parent
2f88f1da59
commit
5f97137f4b
18 changed files with 139 additions and 18 deletions
|
@ -72,7 +72,7 @@ function saveData() {
|
|||
}
|
||||
}
|
||||
}
|
||||
console.log("ENF OF SAVING")
|
||||
console.log("END OF SAVING")
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -46,10 +46,11 @@ var mastodonAPI = function(config) {
|
|||
}
|
||||
}
|
||||
}
|
||||
queryStringAppend += "limit=12"
|
||||
// ajax function
|
||||
var http = new XMLHttpRequest()
|
||||
var url = apiBase + endpoint;
|
||||
console.log(queryStringAppend)
|
||||
console.log(apiBase + endpoint + queryStringAppend)
|
||||
http.open("GET", apiBase + endpoint + queryStringAppend, true);
|
||||
|
||||
// Send the proper header information along with the request
|
||||
|
|
|
@ -5,6 +5,7 @@ var loadImages = true;
|
|||
// used to dedupe on append/insert
|
||||
var knownIds = [];
|
||||
var max_id ;
|
||||
var since_id;
|
||||
|
||||
WorkerScript.onMessage = function(msg) {
|
||||
/*
|
||||
|
@ -16,10 +17,23 @@ WorkerScript.onMessage = function(msg) {
|
|||
*/
|
||||
// this is not elegant. it's max_id and ids from MyList
|
||||
if (msg.params[1]) {
|
||||
max_id = msg.params[0]["data"]
|
||||
knownIds = msg.params[1]["data"]
|
||||
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()
|
||||
}
|
||||
if ( msg.params[2]["name"] === "ids" ) {
|
||||
knownIds = msg.params[2]["data"]
|
||||
msg.params.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** order notifications in ASC order */
|
||||
function orderNotifications(items){
|
||||
for (var i = items.length-1; i > 0; i--) {
|
||||
|
@ -130,30 +144,31 @@ WorkerScript.onMessage = function(msg) {
|
|||
}
|
||||
}
|
||||
|
||||
console.log("Get em all?")
|
||||
if(msg.model && items.length) {
|
||||
addDataToModel(msg.model, msg.mode, items)
|
||||
WorkerScript.sendMessage({ 'updatedAll': true})
|
||||
}
|
||||
/*if(msg.action === "notifications")
|
||||
orderNotifications(items)*/
|
||||
console.log("Get em all?")
|
||||
WorkerScript.sendMessage({ 'updatedAll': true})
|
||||
});
|
||||
}
|
||||
|
||||
//WorkerScript.sendMessage({ 'notifyNewItems': length - i })
|
||||
|
||||
function addDataToModel (model, mode, items) {
|
||||
|
||||
var length = items.length;
|
||||
console.log("Fetched > " +length + " in " + mode)
|
||||
var i
|
||||
if (mode === "append") {
|
||||
|
||||
for(i = 0; i <= length-1; i++) {
|
||||
if ( knownIds.indexOf( items[i]["id"]) === -1) {
|
||||
console.log("max: " + max_id + " i: " + items[i]["id"] + " known: " + knownIds[0])
|
||||
if ( items[i]["id"] < max_id && items[i]["id"] < knownIds[0]) {
|
||||
if ( items[i]["id"] < max_id ) {
|
||||
model.append(items[i])
|
||||
} else {
|
||||
model.insert(0,items[i])
|
||||
} else {
|
||||
console.log("max: " + max_id + " i: " + items[i]["id"] + " known: " + knownIds[knownIds.length-1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,12 @@ SilicaListView {
|
|||
pageStack.push(Qt.resolvedUrl("../SettingsPage.qml"), {})
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Clear")
|
||||
onClicked: {
|
||||
clearLast()
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("New Toot")
|
||||
visible: !profilePage
|
||||
|
@ -156,9 +161,9 @@ SilicaListView {
|
|||
openDrawer(contentY - scrollOffset > 0 ? false : true )
|
||||
scrollOffset = contentY
|
||||
}
|
||||
if(contentY+height > footerItem.y && !loadStarted && autoLoadMore) {
|
||||
loadData("append")
|
||||
if(contentY+height > footerItem.y && !deduping && !loadStarted && autoLoadMore) {
|
||||
loadStarted = true
|
||||
loadData("append")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,7 +187,8 @@ SilicaListView {
|
|||
// temporary debugging measure
|
||||
// should be resolved within loadData()
|
||||
if (messageObject.updatedAll){
|
||||
if (model.count > 30) deDouble()
|
||||
if (debug) console.log("Got em all.")
|
||||
if (model.count > 20) deDouble()
|
||||
loadStarted = false
|
||||
}
|
||||
}
|
||||
|
@ -194,15 +200,29 @@ SilicaListView {
|
|||
}
|
||||
|
||||
Timer {
|
||||
triggeredOnStart: false; interval: 5*60*1000; running: true; repeat: true
|
||||
triggeredOnStart: false;
|
||||
interval: {
|
||||
var listInterval = Math.floor(Math.random() * 60)*10*1000
|
||||
if( title === "Home" ) listInterval = 20*60*1000
|
||||
if( title === "Local" ) listInterval = 10*60*1000
|
||||
if( title === "Federated" ) listInterval = 30*60*1000
|
||||
if( title === "Bookmarks" ) listInterval = 40*60*1000
|
||||
if( title === "Notifications" ) listInterval = 12*60*1000
|
||||
|
||||
if(debug) console.log(title + ' interval: ' + listInterval)
|
||||
return listInterval
|
||||
}
|
||||
running: true;
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if(debug) console.log(title + ' ' +Date().toString())
|
||||
if(debug) console.log(title + ' ' + Date().toString())
|
||||
// let's avoid pre and appending at the same time!
|
||||
if ( ! loadStarted && ! deduping ) loadData("prepend")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* NOT actually doing deduping :)
|
||||
* utility called on updates to model to remove remove Duplicates:
|
||||
* the dupes are probably a result of improper syncing of the models
|
||||
* this is temporary and can probaly be removed because of the
|
||||
|
@ -226,8 +246,16 @@ SilicaListView {
|
|||
}
|
||||
//if (debug) console.log(ids)
|
||||
if (debug) console.log(uniqueItems.length)
|
||||
if (debug) console.log( "maxminusone?:" + model.get(model.count - 2).id )
|
||||
if (debug) console.log( "max?:" + model.get(model.count - 1).id )
|
||||
|
||||
if ( uniqueItems.length < model.count) {
|
||||
|
||||
// it seems that only the last one, is an issue
|
||||
/*if (model.get(model.count - 1).id > model.get(model.count - 2).id){
|
||||
model.remove(model.count - 1,1)
|
||||
}*/
|
||||
|
||||
if (debug) console.log(model.count)
|
||||
for(j = 0; j <= uniqueItems.length - 1 ; j++) {
|
||||
seenIt = 0
|
||||
|
@ -261,6 +289,23 @@ SilicaListView {
|
|||
return unique;
|
||||
}
|
||||
|
||||
|
||||
/* 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
|
||||
*
|
||||
*/
|
||||
|
@ -288,11 +333,15 @@ SilicaListView {
|
|||
if (mode === "prepend" && model.count) {
|
||||
p.push({name:'since_id', data: model.get(0).id})
|
||||
}
|
||||
|
||||
//if (debug) console.log(JSON.stringify(uniqueIds))
|
||||
if(title === "Local") {
|
||||
type = "timelines/public"
|
||||
p.push({name:'local', data: "true"})
|
||||
}
|
||||
// we push the ids via params which we remove in the WorkerScript
|
||||
if (model.count) {
|
||||
p.push({name:'ids', data: uniqueIds})
|
||||
}
|
||||
//if (debug) console.log(JSON.stringify(uniqueIds))
|
||||
|
||||
var msg = {
|
||||
'action' : type,
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>Nichts gefunden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>No encontrado nada</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>Rien trouvé</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>Niente trovato</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>Niets gevonden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>Nic nie znaleziono</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>Ничего не найдено</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>Inget hittades</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>没有发现任何东西</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
<source>Nothing found</source>
|
||||
<translation>Nothing found</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Clear</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfileHeader</name>
|
||||
|
|
Loading…
Reference in a new issue