[-]
[+]
|
Changed |
_service:tar_git:harbour-tooterb.spec
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,7 +2,7 @@
<service name="tar_git">
<param name="url">https://github.com/poetaster/harbour-tooter.git</param>
<param name="branch">master</param>
- <param name="revision">1.1.0 </param>
+ <param name="revision">1.1.2</param>
<param name="debian">N</param>
<param name="dumb">N</param>
</service>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-tooterb-1.1.2.tar.bz2/harbour-tooterb.pro.user
^
|
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.15.2, 2022-11-29T17:24:15. -->
+<!-- Written by QtCreator 4.15.2, 2022-12-02T16:03:12. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@@ -112,7 +112,7 @@
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
- <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">true</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.2">
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-tooterb-1.1.2.tar.bz2/qml/lib/API.js
^
|
@@ -72,7 +72,7 @@
}
}
}
- console.log("ENF OF SAVING")
+ console.log("END OF SAVING")
});
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-tooterb-1.1.2.tar.bz2/qml/lib/Mastodon.js
^
|
@@ -16,6 +16,57 @@
return config[key];
},
+ /*
+ * function to retrieve the Link header
+ */
+
+ getLink: function (endpoint) {
+ // variables
+ var queryData, callback,
+ queryStringAppend = "?";
+
+ // check with which arguments we're supplied
+ if (typeof arguments[1] === "function") {
+ queryData = {};
+ callback = arguments[1];
+ } else {
+ queryData = arguments[1];
+ callback = arguments[2];
+ }
+ // build queryData Object into a URL Query String
+ for (var i in queryData) {
+ if (queryData.hasOwnProperty(i)) {
+ if (typeof queryData[i] === "string") {
+ queryStringAppend += queryData[i] + "&";
+ } else if (typeof queryData[i] === "object") {
+ queryStringAppend += queryData[i].name + "="+ queryData[i].data + "&";
+ }
+ }
+ }
+ var http = new XMLHttpRequest()
+ var url = apiBase + endpoint;
+ console.log("HEAD" + apiBase + endpoint + queryStringAppend)
+
+ http.open("HEAD", apiBase + endpoint + queryStringAppend, true);
+ // Send the proper header information along with the request
+ http.setRequestHeader("Authorization", "Bearer " + config.api_user_token);
+ http.setRequestHeader("Content-Type", "application/json");
+ http.setRequestHeader("Connection", "close");
+
+ http.onreadystatechange = function() {
+ if (http.readyState === 4) {
+ if (http.status === 200) {
+ callback( http.getResponseHeader("Link") , http.status)
+ console.log("Successful HEAD API request to " +apiBase+endpoint);
+ } else {
+ console.log("error: " + http.status)
+ }
+ }
+ }
+ http.send();
+
+ },
+
get: function (endpoint) {
// for GET API calls
// can be called with two or three parameters
@@ -46,10 +97,11 @@
}
}
}
+ //queryStringAppend += "limit=20"
// 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
@@ -60,8 +112,8 @@
http.onreadystatechange = function() { // Call a function when the state changes.
if (http.readyState === 4) {
if (http.status === 200) {
- console.log("Successful GET API request to " +apiBase+endpoint);
callback(JSON.parse(http.response),http.status)
+ console.log("Successful GET API request to " +apiBase+endpoint);
} else {
console.log("error: " + http.status)
}
@@ -219,7 +271,7 @@
var http = new XMLHttpRequest()
var url = config.instance + "/oauth/token";
var params = 'client_id=' + client_id + '&client_secret=' + client_secret + '&redirect_uri=' + redirect_uri + '&grant_type=authorization_code&code=' + code;
- console.log(params)
+ // console.log(params)
http.open("POST", url, true);
// Send the proper header information along with the request
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-tooterb-1.1.2.tar.bz2/qml/lib/Worker.js
^
|
@@ -2,13 +2,39 @@
var loadImages = true;
+// used to dedupe on append/insert
+var knownIds = [];
+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))
+*/
+
+ // this is not elegant. it's max_id and ids from MyList
+
+ if (msg.params[1]) {
+ 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){
@@ -20,7 +46,7 @@
/** Logged-in status */
if (!msg.conf || !msg.conf.login) {
- console.log("Not loggedin")
+ //console.log("Not loggedin")
return;
}
@@ -28,12 +54,28 @@
if (typeof msg.conf['loadImages'] !== "undefined")
loadImages = msg.conf['loadImages']
- /** POST statuses */
+
+ /* init API statuses */
+
var API = mastodonAPI({ instance: msg.conf.instance, api_user_token: msg.conf.api_user_token});
+
+ /* for some actions
+ * we have to retrieve the Link header
+ */
+
+ if (msg.action === "bookmarks"){
+ API.getLink(msg.action, msg.params, function(data) {
+ console.log(JSON.stringify(data))
+ WorkerScript.sendMessage({ 'Header': data })
+ });
+ }
+
+ /** POST statuses */
+
if (msg.method === "POST"){
API.post(msg.action, msg.params, function(data) {
if (msg.bgAction){
- console.log(JSON.stringify(data))
+ //console.log(JSON.stringify(data))
} else if (msg.action === "statuses") {
// status posted
if(msg.model){
@@ -45,7 +87,7 @@
} else {
for (var i in data) {
if (data.hasOwnProperty(i)) {
- console.log(JSON.stringify(data[i]))
+ //console.log(JSON.stringify(data[i]))
WorkerScript.sendMessage({ 'action': msg.action, 'success': true, key: i, "data": data[i]})
}
}
@@ -55,21 +97,26 @@
}
API.get(msg.action, msg.params, function(data) {
+
var items = [];
+ //console.log(data)
+
for (var i in data) {
var item;
if (data.hasOwnProperty(i)) {
if(msg.action === "accounts/search") {
item = parseAccounts([], "", data[i]);
- console.log(JSON.stringify(data[i]))
+ //console.log(JSON.stringify(data[i]))
+ console.log("has own data")
+
items.push(item)
} else if(msg.action === "notifications") {
// notification
- console.log("Get notification list")
- console.log(JSON.stringify(data[i]))
+ //console.log("Get notification list")
+ //console.log(JSON.stringify(data[i]))
item = parseNotification(data[i]);
- items.push(item)
+ items.push(item);
} else if(msg.action.indexOf("statuses") >-1 && msg.action.indexOf("context") >-1 && i === "ancestors") {
// status ancestors toots - conversation
@@ -79,8 +126,9 @@
item['id'] = item['status_id'];
if (typeof item['attachments'] === "undefined")
item['attachments'] = [];
- items.push(item)
- console.log(JSON.stringify(data[i][j]))
+ // don't permit doubles
+ items.push(item);
+ //console.log(JSON.stringify(data[i][j]))
}
addDataToModel (msg.model, "prepend", items);
items = [];
@@ -94,8 +142,8 @@
item['id'] = item['status_id'];
if (typeof item['attachments'] === "undefined")
item['attachments'] = [];
- items.push(item)
- console.log(JSON.stringify(data[i][j]))
+ items.push(item);
+ //console.log(JSON.stringify(data[i][j]))
}
addDataToModel (msg.model, "append", items);
items = [];
@@ -104,7 +152,8 @@
//console.log("Get Toot")
item = parseToot(data[i]);
item['id'] = item['status_id']
- items.push(item)
+ items.push(item);
+
} else {
WorkerScript.sendMessage({ 'action': msg.action, 'success': true, key: i, "data": data[i] })
@@ -112,29 +161,65 @@
}
}
- if(msg.model && items.length)
+ 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})
});
}
//WorkerScript.sendMessage({ 'notifyNewItems': length - i })
+
function addDataToModel (model, mode, items) {
+
var length = items.length;
- console.log("Fetched > " +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) {
+ model.append(items[i])
+ } else {
+ console.log("nope: " + items[i]["id"] )
+ }
+ }
+
+ //model.append(items)
+
} else if (mode === "prepend") {
- for(var i = length-1; i >= 0 ; i--) {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-tooterb-1.1.2.tar.bz2/qml/pages/LoginPage.qml
^
|
@@ -135,23 +135,18 @@
case "embed:contentOrientationChanged":
break
case "webview:action":
- if ( data.topic != lon ) {
- //webview.runJavaScript("return latlon('" + lat + "','" + lon + "')");
- //if (debug) console.debug(data.topic)
- //if (debug) console.debug(data.also)
- //if (debug) console.debug(data.src)
- }
break
}
}
visible: false
//opacity: 0
- anchors {
+ anchors.fill: parent
+ /*{
top: parent.top
left: parent.left
right: parent.right
bottom: parent.bottom
- }
+ }*/
onLoadingChanged: {
if(debug) console.log('loading changed: ' + url)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-tooterb-1.1.2.tar.bz2/qml/pages/components/MyList.qml
^
|
@@ -18,9 +18,12 @@
property bool loadStarted: false
property int scrollOffset
property string action: ""
+ property string linkprev: ""
property variant vars
property variant conf
property bool notifier: false
+ property bool deduping: false
+ property variant uniqueIds: []
model: mdl
@@ -76,7 +79,6 @@
pageStack.push(Qt.resolvedUrl("../SettingsPage.qml"), {})
}
}
-
MenuItem {
text: qsTr("New Toot")
visible: !profilePage
@@ -116,7 +118,10 @@
}
onCountChanged: {
- loadStarted = false
+ if (debug) console.log("count changed on: " + title)
+ //deDouble()
+ //loadStarted = false
+
/*contentY = scrollOffset
console.log("CountChanged!")*/
}
@@ -131,7 +136,7 @@
anchors.bottomMargin: Theme.paddingLarge
visible: false
onClicked: {
- loadData("append")
+ if (!loadStarted && !deduping) loadData("append")
}
}
@@ -151,9 +156,9 @@
openDrawer(contentY - scrollOffset > 0 ? false : true )
scrollOffset = contentY
}
- if(contentY+height > footerItem.y && !loadStarted && autoLoadMore) {
- loadData("append")
- loadStarted = true
+ if(contentY+height > footerItem.y && !deduping && !loadStarted && autoLoadMore) {
+ loadStarted = true
+ loadData("append")
}
}
@@ -165,37 +170,171 @@
onMessage: {
if (messageObject.error){
if (debug) console.log(JSON.stringify(messageObject))
+ } else {
+ if (debug) console.log(JSON.stringify(messageObject))
+ loadStarted = false
}
+
if (messageObject.fireNotification && notifier){
Logic.notifier(messageObject.data)
}
+
+ // temporary debugging measure
+ if (messageObject.updatedAll){
+ if (debug) console.log("Got em all.")
+ if (model.count > 20) deDouble()
+ loadStarted = false
+ }
+ if (messageObject.Header) {
+ //if (debug) console.log(JSON.stringify(messageObject))
+ var matches = /max_id=([0-9]+)/.exec(messageObject.Header);
+ var link = matches[0].split("=")[1];
+ if (debug) console.log("link: " + link)
+ linkprev = link
+ }
}
}
Component.onCompleted: {
loadData("prepend")
+ if (debug) console.log("MyList completed: " + title)
}
Timer {
- triggeredOnStart: false; interval: 5*60*1000; running: true; repeat: true
+ triggeredOnStart: false;
+ interval: {
+
+ /* this is hamfisted */
+ 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())
- loadData("prepend")
+ 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
+ * loadData method passing in to the WorkerScript
+ */
+ function deDouble(){
+
+ deduping = true
+ var ids = []
+ var uniqueItems = []
+ var i
+ var j
+ var seenIt = 0
+
+ if (debug) console.log(model.count)
+
+ for(i = 0 ; i < model.count ; i++) {
+ ids.push(model.get(i).id)
+ uniqueItems = removeDuplicates(ids)
+
+ }
+ //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
+ for(i = 0 ; i < model.count - 1 ; i++) {
+ if (model.get(i).id === uniqueItems[j]){
+ seenIt = seenIt+1
+ if (seenIt > 1) {
+ if (debug) console.log(uniqueItems[j] + " - " + seenIt)
+
+ // model.remove(i,1) // (model.get(i))
+ seenIt = seenIt-1
+ }
+ }
+ }
+ }
+ }
+
+ deduping = false
+ }
+
+ /* utility function because this version of qt doesn't support modern javascript
+ *
+ */
+ function removeDuplicates(arr) {
+ var unique = [];
+ for(var i=0; i < arr.length; i++){
+ if(unique.indexOf(arr[i]) === -1) {
+ unique.push(arr[i]);
+ }
+ }
+ return unique;
+ }
+
+
+ /* Principle load function, uses websocket's worker.js
+ *
+ */
+
function loadData(mode) {
+
+ if (debug) console.log('loadData called: ' + mode + " in " + title)
+ // since the worker adds Duplicates
+ // we pass in current ids in the model
+ // and skip those on insert append in the worker
+ for(var i = 0 ; i < model.count ; i++) {
+ uniqueIds.push(model.get(i).id)
+ //if (debug) console.log(model.get(i).id)
+ }
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-tooterb-1.1.2.tar.bz2/translations/harbour-tooterb-sv.ts
^
|
@@ -165,15 +165,15 @@
<name>MediaItem</name>
<message>
<source>Image</source>
- <translation type="unfinished"></translation>
+ <translation>Bild</translation>
</message>
<message>
<source>Video</source>
- <translation type="unfinished"></translation>
+ <translation>Video</translation>
</message>
<message>
<source>PDF document</source>
- <translation type="unfinished"></translation>
+ <translation>PDF-dokument</translation>
</message>
</context>
<context>
@@ -377,7 +377,7 @@
</message>
<message>
<source>Development</source>
- <translation type="unfinished"></translation>
+ <translation>Utveckling</translation>
</message>
</context>
<context>
|