2017-06-07 08:56:42 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
import "../lib/API.js" as Logic
|
|
|
|
import "./components/"
|
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
|
|
|
|
Page {
|
|
|
|
property ListModel tweets;
|
2020-04-16 01:37:11 +03:00
|
|
|
property string display_name : "";
|
2017-06-07 08:56:42 +03:00
|
|
|
property string username : "";
|
|
|
|
property string profileImage : "";
|
|
|
|
property int user_id;
|
|
|
|
property int statuses_count;
|
|
|
|
property int following_count;
|
|
|
|
property int followers_count;
|
|
|
|
property int favourites_count;
|
2017-07-04 17:57:50 +03:00
|
|
|
property int reblogs_count;
|
2017-06-07 08:56:42 +03:00
|
|
|
property int count_moments;
|
2020-04-16 01:37:11 +03:00
|
|
|
property string profile_background: "";
|
2017-06-07 08:56:42 +03:00
|
|
|
property string note: "";
|
2020-04-16 01:37:11 +03:00
|
|
|
property string url: "";
|
2017-06-07 08:56:42 +03:00
|
|
|
|
|
|
|
property bool locked : false;
|
|
|
|
property date created_at;
|
|
|
|
property bool following : false;
|
|
|
|
property bool requested : false;
|
|
|
|
property bool followed_by : false;
|
|
|
|
property bool blocking : false;
|
|
|
|
property bool muting : false;
|
|
|
|
property bool domain_blocking : false;
|
|
|
|
|
|
|
|
|
|
|
|
WorkerScript {
|
|
|
|
id: worker
|
|
|
|
source: "../lib/Worker.js"
|
|
|
|
onMessage: {
|
|
|
|
console.log(JSON.stringify(messageObject))
|
2017-06-07 17:09:41 +03:00
|
|
|
if(messageObject.action.indexOf("accounts/search") > -1 ){
|
|
|
|
user_id = messageObject.data.id
|
|
|
|
followers_count = messageObject.data.followers_count
|
|
|
|
following_count = messageObject.data.following_count
|
2017-11-01 02:27:48 +03:00
|
|
|
username = messageObject.data.acct
|
2020-04-16 01:37:11 +03:00
|
|
|
display_name = messageObject.data.display_name
|
2017-06-07 17:09:41 +03:00
|
|
|
profileImage = messageObject.data.avatar_static
|
|
|
|
|
|
|
|
var msg = {
|
|
|
|
'action' : "accounts/relationships/",
|
|
|
|
'params' : [ {name: "id", data: user_id}],
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
list.loadData("prepend")
|
|
|
|
}
|
|
|
|
|
2017-06-07 08:56:42 +03:00
|
|
|
if(messageObject.action === "accounts/relationships/"){
|
|
|
|
console.log(JSON.stringify(messageObject))
|
|
|
|
following= messageObject.data.following
|
|
|
|
requested= messageObject.data.requested
|
|
|
|
followed_by= messageObject.data.followed_by
|
|
|
|
blocking= messageObject.data.blocking
|
|
|
|
muting= messageObject.data.muting
|
|
|
|
domain_blocking= messageObject.data.domain_blocking
|
|
|
|
}
|
|
|
|
switch (messageObject.key) {
|
|
|
|
case 'followers_count':
|
|
|
|
followers_count = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'following_count':
|
|
|
|
following_count = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'acct':
|
2020-04-16 01:37:11 +03:00
|
|
|
// line below was commented out, reason unknown
|
|
|
|
// username = messageObject.data
|
2017-06-07 08:56:42 +03:00
|
|
|
break;
|
2020-04-16 01:37:11 +03:00
|
|
|
case 'locked':m
|
2017-06-07 08:56:42 +03:00
|
|
|
locked = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'created_at':
|
|
|
|
created_at = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'statuses_count':
|
|
|
|
statuses_count = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'note':
|
|
|
|
note = messageObject.data
|
|
|
|
break;
|
2020-04-16 01:37:11 +03:00
|
|
|
case 'url':
|
|
|
|
url = messageObject.data
|
|
|
|
break;
|
2017-06-07 08:56:42 +03:00
|
|
|
case 'following':
|
|
|
|
following = messageObject.data
|
|
|
|
followers_count = followers_count + (following ? 1 : - 1)
|
|
|
|
break;
|
|
|
|
case 'muting':
|
|
|
|
muting = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'muting':
|
|
|
|
muting = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'blocking':
|
|
|
|
blocking = messageObject.data
|
|
|
|
followers_count = followers_count + (blocking ? -1 : 0)
|
|
|
|
break;
|
|
|
|
case 'followed_by':
|
|
|
|
followed_by = messageObject.data
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// The effective value will be restricted by ApplicationWindow.allowedOrientations
|
|
|
|
allowedOrientations: Orientation.All
|
|
|
|
Component.onCompleted: {
|
2017-06-07 17:09:41 +03:00
|
|
|
var msg;
|
2017-11-01 02:27:48 +03:00
|
|
|
|
2017-06-07 17:09:41 +03:00
|
|
|
if (user_id) {
|
|
|
|
msg = {
|
|
|
|
'action' : "accounts/relationships/",
|
|
|
|
'params' : [ {name: "id", data: user_id}],
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
msg = {
|
|
|
|
'action' : "accounts/"+user_id,
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
} else {
|
2017-11-01 02:27:48 +03:00
|
|
|
var instance = Logic.conf['instance'].split("//")
|
2017-06-07 17:09:41 +03:00
|
|
|
msg = {
|
2017-11-01 02:27:48 +03:00
|
|
|
'action' : "accounts/search?limit=1&q="+username.replace("@"+instance[1], ""),
|
2017-06-07 17:09:41 +03:00
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
}
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyList {
|
2017-06-07 17:09:41 +03:00
|
|
|
id: list
|
2017-06-07 08:56:42 +03:00
|
|
|
header: ProfileHeader {
|
|
|
|
id: header
|
2020-04-16 01:37:11 +03:00
|
|
|
title: display_name
|
2017-06-07 08:56:42 +03:00
|
|
|
description: '@'+username
|
|
|
|
image: profileImage
|
|
|
|
}
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
bottom: expander.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
clip: true
|
|
|
|
|
2017-06-16 17:45:04 +03:00
|
|
|
mdl: ListModel {}
|
2017-06-07 08:56:42 +03:00
|
|
|
type: "accounts/"+user_id+"/statuses"
|
|
|
|
vars: {}
|
2017-06-07 17:09:41 +03:00
|
|
|
conf: Logic.conf
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExpandingSectionGroup {
|
|
|
|
id: expander
|
|
|
|
//currentIndex: 0
|
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
ExpandingSection {
|
|
|
|
title: qsTr("Summary")
|
|
|
|
content.sourceComponent: Column {
|
|
|
|
spacing: Theme.paddingMedium
|
|
|
|
anchors.bottomMargin: Theme.paddingLarge
|
|
|
|
DetailItem {
|
|
|
|
visible: followers_count ? true : false
|
|
|
|
label: qsTr("Followers")
|
|
|
|
value: followers_count
|
|
|
|
}
|
|
|
|
DetailItem {
|
|
|
|
visible: following_count ? true : false
|
|
|
|
label: qsTr("Following")
|
|
|
|
value: (following_count)
|
|
|
|
}
|
|
|
|
DetailItem {
|
|
|
|
visible: statuses_count ? true : false
|
|
|
|
label: qsTr("Statuses")
|
|
|
|
value: (statuses_count)
|
|
|
|
}
|
|
|
|
DetailItem {
|
|
|
|
visible: favourites_count ? true : false
|
|
|
|
label: qsTr("Favourites")
|
|
|
|
value: (favourites_count)
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
spacing: Theme.paddingMedium
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
Button {
|
|
|
|
id: btnFollow
|
|
|
|
text: (following ? qsTr("Unfollow") : (requested ? qsTr("Follow request sent!") : qsTr("Follow")))
|
|
|
|
onClicked: {
|
|
|
|
var msg = {
|
|
|
|
'method' : 'POST',
|
|
|
|
'params' : [],
|
|
|
|
'action' : "accounts/" + user_id + (following ? '/unfollow':'/follow'),
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
id: btnMute
|
|
|
|
text: (muting ? qsTr("Unmute") : qsTr("Mute"))
|
|
|
|
onClicked: {
|
|
|
|
var msg = {
|
|
|
|
'method' : 'POST',
|
|
|
|
'params' : [],
|
|
|
|
'action' : "accounts/" + user_id + (muting ? '/unmute':'/mute'),
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
id: btnBlock
|
|
|
|
text: (blocking ? qsTr("Unblock") : qsTr("Block") )
|
|
|
|
onClicked: {
|
|
|
|
var msg = {
|
|
|
|
'method' : 'POST',
|
|
|
|
'params' : [],
|
|
|
|
'action' : "accounts/" + user_id + (blocking ? '/unblock':'/block'),
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
text: " "
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-04-16 01:37:11 +03:00
|
|
|
ExpandingSection {
|
|
|
|
title: qsTr("Bio")
|
|
|
|
content.sourceComponent: Column {
|
|
|
|
spacing: Theme.paddingMedium
|
|
|
|
anchors.bottomMargin: Theme.paddingLarge
|
|
|
|
Text {
|
|
|
|
x: Theme.horizontalPageMargin
|
|
|
|
width: parent.width - ( 2 * Theme.horizontalPageMargin )
|
|
|
|
id: txtnote
|
|
|
|
text: note
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
color: Theme.secondaryColor
|
|
|
|
linkColor: Theme.secondaryHighlightColor
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
onLinkActivated: {
|
|
|
|
var test = link.split("/")
|
|
|
|
console.log(link)
|
|
|
|
console.log(JSON.stringify(test))
|
|
|
|
console.log(JSON.stringify(test.length))
|
2017-06-07 08:56:42 +03:00
|
|
|
|
2020-04-16 01:37:11 +03:00
|
|
|
if (test.length === 5 && (test[3] === "tags" || test[3] === "tag") ) {
|
|
|
|
pageStack.pop(pageStack.find(function(page) {
|
|
|
|
var check = page.isFirstPage === true;
|
|
|
|
if (check)
|
|
|
|
page.onLinkActivated(link)
|
|
|
|
return check;
|
|
|
|
}));
|
|
|
|
send(link)
|
|
|
|
|
|
|
|
} else if (test.length === 4 && test[3][0] === "@" ) {
|
|
|
|
tlSearch.search = decodeURIComponent("@"+test[3].substring(1)+"@"+test[2])
|
|
|
|
slideshow.positionViewAtIndex(4, ListView.SnapToItem)
|
|
|
|
navigation.navigateTo('search')
|
|
|
|
|
|
|
|
} else {
|
|
|
|
Qt.openUrlExternally(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Column {
|
|
|
|
spacing: Theme.paddingMedium
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
Button {
|
|
|
|
id: btnUrl
|
|
|
|
text: qsTr("Open Profile in Browser")
|
|
|
|
onClicked: {
|
|
|
|
Qt.openUrlExternally(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
text: " "
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|