Updating timelines and additional changes

This commit is contained in:
Dusko Angirevic 2017-06-14 16:42:28 +02:00
parent 918a86aa9c
commit b59fe852c7
15 changed files with 192 additions and 85 deletions

View file

@ -43,7 +43,9 @@ CONFIG += sailfishapp_i18n
# planning to localize your app, remember to comment out the
# following TRANSLATIONS line. And also do not forget to
# modify the localized app name in the the .desktop file.
TRANSLATIONS += translations/harbour-tooter-de.ts
TRANSLATIONS += \
translations/harbour-tooter-fr.ts \
translations/harbour-tooter-oc.ts
DISTFILES += \
qml/lib/API.js \

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.1, 2017-06-13T09:21:48. -->
<!-- Written by QtCreator 4.0.1, 2017-06-13T16:51:37. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -8,7 +8,7 @@
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
@ -414,7 +414,7 @@
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

@ -31,6 +31,7 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import "pages"
import org.nemomobile.notifications 1.0
import "./lib/API.js" as Logic
ApplicationWindow

View file

@ -25,17 +25,18 @@ WorkerScript.onMessage = function(msg) {
API.get(msg.action, msg.params, function(data) {
var items = [];
for (var i in data) {
var item;
if (data.hasOwnProperty(i)) {
if(msg.action === "accounts/search") {
var item = parseAccounts(data[i]);
item = parseAccounts(data[i]);
items.push(item)
} else if(msg.action === "notifications") {
console.log("Is notification... parsing...")
var item = parseNotification(data[i]);
item = parseNotification(data[i]);
items.push(item)
} else if (data[i].hasOwnProperty("content")){
console.log("Is toot... parsing...")
var item = parseToot(data[i]);
item = parseToot(data[i]);
item['id'] = item['status_id']
items.push(item)
} else {
@ -83,13 +84,15 @@ function parseNotification(data){
var item = {
id: data.id,
type: data.type,
created_at: new Date(data.created_at)
created_at: new Date(data.created_at),
section: new Date(data["created_at"]).toLocaleDateString()
};
switch (item['type']){
case "mention":
item = parseToot(data.status)
item['typeIcon'] = "image://theme/icon-s-retweet"
item['typeIcon'] = "image://theme/icon-s-alarm"
item['type'] = "mention";
break;
case "reblog":
item = parseToot(data.status)
@ -122,6 +125,8 @@ function parseNotification(data){
item['id'] = data.id
//WorkerScript.sendMessage({ 'fireNotification': true, "data": item})
return item;
}
@ -147,6 +152,7 @@ function parseToot (data){
item['status_reblog'] = data["reblog"] ? true : false
item['status_content'] = data["content"]
item['status_created_at'] = item['created_at'] = new Date(data["created_at"]);
item['section'] = new Date(data["created_at"]).toLocaleDateString()
item['status_reblogs_count'] = data["reblogs_count"]
item['status_favourites_count'] = data["favourites_count"]
item['status_reblogged'] = data["reblogged"]
@ -172,56 +178,7 @@ function parseToot (data){
//item['application_name'] = data["application"]["name"]
//item['application_website'] = data["application"]["website"]
// account
/*
*/
/*item['type'] = "";
item['retweetScreenName'] = '';
item['isVerified'] = false;
item['isReblog'] = false;
item['favourited'] = data['favourited'];
item['reblogged'] = data['reblogged'];
item['muted'] = data['muted'];
item['status_reblogs_count'] = data['reblogs_count'];
item['status_favourites_count'] = data['favourites_count'];
if(data['id']){
item['status_id'] = data['id'];
}
if(data['created_at']){
item['status_created_at'] = data['created_at'];
}
if(data['account']){
item['status_account_id'] = data['account']['id'];
item['status_account_username'] = data['account']['acct'];
item['status_account_display_name'] = data['account']['display_name'];
item['status_account_locked'] = data['account']['locked'];
item['status_account_avatar'] = data['account']['avatar'];
}
if(data['reblog']){
item['retweetScreenName'] = data['account']['username'];
item['type'] = "reblog";
item['reblog_id'] = data['reblog']['id'];
item['account_id'] = data['reblog']['account']['id'];
item['account_username'] = data['reblog']['account']['username'];
item['account_display_name'] = data['reblog']['account']['display_name'];
item['account_locked'] = data['reblog']['account']['locked'];
item['account_avatar'] = data['reblog']['account']['avatar'];
item['status_reblogs_count'] = data['reblog']['reblogs_count'];
item['status_favourites_count'] = data['reblog']['favourites_count'];
item['status_favourited'] = data['reblog']['favourited'];
item['status_reblogged'] = data['reblog']['reblogged'];
item['status_muted'] = data['reblog']['muted'];
}
*/
item['content'] = data['content'].replace(/(<([^>]+)>)/ig,"");
/*for(var i = 0; i < data['tags'].length ; i++){
var tag = data['tags'][i]['name'];
@ -240,7 +197,7 @@ function parseToot (data){
}
item['content'] = item['content'].join(" ").autoLink()
console.log(JSON.stringify(item))
//console.log(JSON.stringify(item))
return item;
}

View file

@ -129,4 +129,7 @@ Page {
}
}
}
Component.onCompleted: {
toot.cursorPosition = toot.text.length
}
}

View file

@ -80,6 +80,7 @@ Page {
id: tlNotifications;
title: qsTr("Notifications")
type: "notifications"
notifier: true
mdl: Logic.modelTLnotifications
width: parent.width
height: parent.height

View file

@ -2,9 +2,20 @@ import QtQuick 2.0
import Sailfish.Silica 1.0
import "../../lib/API.js" as Logic
import "."
import org.nemomobile.notifications 1.0
SilicaListView {
Notification {
id: notification
category: "x-nemo.example"
urgency: Notification.Normal
onClicked: console.log("Clicked")
}
id: myList
property string type;
property string title
@ -17,6 +28,7 @@ SilicaListView {
property string action: ""
property variant vars
property variant conf
property bool notifier : false;
model: mdl
signal notify (string what, int num)
onNotify: {
@ -63,10 +75,6 @@ SilicaListView {
Logic.conf['instance'] = null;
Logic.conf['api_user_token'] = null;
Logic.conf['dysko'] = null;
} else {
Logic.conf['login'] = true
Logic.conf['instance'] = "https://mastodon.social";
Logic.conf['api_user_token'] = '6d8cb23e3ebf3c7a97dd9adf204e47ad159f1a3d07dbbd0325e98981368d8c51';
}
}
}
@ -89,21 +97,8 @@ SilicaListView {
clip: true
section {
property: 'section'
criteria: ViewSection.FullString
delegate: SectionHeader {
text: {
var dat = Date.fromLocaleDateString(locale, created_at);
dat = Format.formatDate(dat, Formatter.TimepointRelativeCurrentDay)
if (dat === "00:00:00" || dat === "00:00") {
visible = false;
height = 0;
return " ";
}else {
return dat;
}
}
text: section
}
}
@ -146,9 +141,55 @@ SilicaListView {
if (messageObject.error){
console.log(JSON.stringify(messageObject))
}
if (messageObject.notifyNewItems){
console.log(JSON.stringify(messageObject.notifyNewItems))
if (messageObject.fireNotification && notifier){
console.log(JSON.stringify(messageObject.data.id))
var item = messageObject.data
item.content = item.content.replace(/(<([^>]+)>)/ig,"").replaceAll("&quot;", "\"")
if(notification.replacesId){
notification.replacesId = 0
}
switch (item.type){
case "favourite":
notification.urgency = Notification.Normal
notification.timestamp = item.created_at
notification.summary = (item.reblog_account_display_name !== "" ? item.reblog_account_display_name : '@'+item.reblog_account_username) + ' ' + qsTr("favourited")
notification.body = item.content
notification.publish()
break;
case "follow":
notification.urgency = Notification.Critical
notification.timestamp = item.created_at
notification.summary = (item.account_display_name !== "" ? item.account_display_name : '@'+item.account_acct)
notification.body = qsTr("followed you")
notification.publish()
break;
case "reblog":
notification.urgency = Notification.Low
notification.timestamp = item.created_at
notification.summary = (item.account_display_name !== "" ? item.account_display_name : '@'+item.account_acct) + ' ' + qsTr("boosted")
notification.body = item.content
notification.publish()
break;
case "mention":
notification.urgency = Notification.Critical
notification.timestamp = item.created_at
notification.summary = (item.account_display_name !== "" ? item.account_display_name : '@'+item.account_acct) + ' ' + qsTr("said")
notification.previewSummary = notification.summary
notification.body = item.content
notification.previewBody = notification.body
notification.publish()
break;
default:
console.log(JSON.stringify(messageObject.data))
break;
}
}
}
}
@ -162,6 +203,14 @@ SilicaListView {
};
worker.sendMessage(msg);
}
Timer {
triggeredOnStart: true; interval: 5*60*1000; running: true; repeat: true
onTriggered: {
console.log(title + ' ' +Date().toString())
loadData("prepend")
}
}
function loadData(mode){
var p = [];
if (mode === "append" && model.count){

View file

@ -101,6 +101,22 @@
<source>Load more</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>boosted</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>favourited</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>followed you</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>said</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -41,7 +41,7 @@
<source>unlisted</source>
<translation>non-listé</translation>
</message>
<message>
<message>
<source>followers only</source>
<translation>abonnés uniquement</translation>
</message>
@ -80,12 +80,43 @@
<translation>Nouveau pouet</translation>
</message>
</context>
<context>
<name>MiniStatus</name>
<message>
<source>boosted</source>
<translation type="unfinished">a partagé</translation>
</message>
<message>
<source>favourited</source>
<translation type="unfinished">a ajouté à ses favoris</translation>
</message>
<message>
<source>followed you</source>
<translation type="unfinished">vous suit</translation>
</message>
</context>
<context>
<name>MyList</name>
<message>
<source>Load more</source>
<translation>Charger davantage</translation>
</message>
<message>
<source>favourited</source>
<translation type="unfinished">a ajouté à ses favoris</translation>
</message>
<message>
<source>followed you</source>
<translation type="unfinished">vous suit</translation>
</message>
<message>
<source>boosted</source>
<translation type="unfinished">a partagé</translation>
</message>
<message>
<source>said</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -80,12 +80,43 @@
<translation>Nòu tut</translation>
</message>
</context>
<context>
<name>MiniStatus</name>
<message>
<source>boosted</source>
<translation type="unfinished">a tornat partejar</translation>
</message>
<message>
<source>favourited</source>
<translation type="unfinished">a mes en favorit</translation>
</message>
<message>
<source>followed you</source>
<translation type="unfinished">vos sèc</translation>
</message>
</context>
<context>
<name>MyList</name>
<message>
<source>Load more</source>
<translation>Cargar mai</translation>
</message>
<message>
<source>favourited</source>
<translation type="unfinished">a mes en favorit</translation>
</message>
<message>
<source>followed you</source>
<translation type="unfinished">vos sèc</translation>
</message>
<message>
<source>boosted</source>
<translation type="unfinished">a tornat partejar</translation>
</message>
<message>
<source>said</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -77,11 +77,30 @@
</message>
<message>
<source>New Toot</source>
<translation type="unfinished"></translation>
<translation>New</translation>
</message>
</context>
<context>
<name>MiniStatus</name>
<message>
<source>boosted</source>
<translation>boosted</translation>
</message>
<message>
<source>favourited</source>
<translation>favourited</translation>
</message>
<message>
<source>followed you</source>
<translation>followed you</translation>
</message>
</context>
<context>
<name>MyList</name>
<message>
<source>Load more</source>
<translation>Load more</translation>
</message>
<message>
<source>boosted</source>
<translation type="unfinished">boosted</translation>
@ -94,12 +113,9 @@
<source>followed you</source>
<translation type="unfinished">followed you</translation>
</message>
</context>
<context>
<name>MyList</name>
<message>
<source>Load more</source>
<translation>Load more</translation>
<source>said</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>