2020-05-29 21:05:05 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
2020-06-04 12:17:06 +03:00
|
|
|
import QtGraphicalEffects 1.0
|
2020-05-29 21:05:05 +03:00
|
|
|
import "../lib/API.js" as Logic
|
|
|
|
import "./components/"
|
|
|
|
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: profilePage
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
property ListModel tweets
|
|
|
|
property string display_name: ""
|
|
|
|
property string username: ""
|
|
|
|
property string profileImage: ""
|
2020-06-04 12:17:06 +03:00
|
|
|
property string profileBackground: ""
|
|
|
|
property string note: ""
|
|
|
|
property string url: ""
|
2020-06-04 20:44:12 +03:00
|
|
|
property string user_id: ""
|
2020-05-29 21:05:05 +03:00
|
|
|
property int statuses_count
|
|
|
|
property int following_count
|
|
|
|
property int followers_count
|
|
|
|
property bool locked: false
|
2020-06-10 14:26:16 +03:00
|
|
|
property bool bot: false
|
2020-06-18 19:40:24 +03:00
|
|
|
property bool group: false
|
2020-05-29 21:05:05 +03:00
|
|
|
property bool following: false
|
|
|
|
property bool followed_by: false
|
2020-06-16 17:09:28 +03:00
|
|
|
property bool requested: false
|
2020-05-29 21:05:05 +03:00
|
|
|
property bool blocking: false
|
|
|
|
property bool muting: false
|
|
|
|
property bool domain_blocking: false
|
2020-06-04 12:17:06 +03:00
|
|
|
property date created_at
|
2023-10-11 13:39:33 +03:00
|
|
|
property bool debug: true
|
2020-05-29 21:05:05 +03:00
|
|
|
|
|
|
|
WorkerScript {
|
|
|
|
id: worker
|
|
|
|
source: "../lib/Worker.js"
|
|
|
|
onMessage: {
|
2022-12-01 13:00:18 +03:00
|
|
|
if (debug) console.log(JSON.stringify(messageObject))
|
2020-05-29 21:05:05 +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
|
|
|
|
username = messageObject.data.acct
|
|
|
|
display_name = messageObject.data.display_name
|
|
|
|
profileImage = messageObject.data.avatar_static
|
|
|
|
profileBackground = messageObject.data.header_static
|
|
|
|
|
|
|
|
var msg = {
|
|
|
|
'action' : "accounts/relationships/",
|
|
|
|
'params' : [ {name: "id", data: user_id}],
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
list.loadData("prepend")
|
|
|
|
}
|
|
|
|
|
|
|
|
if(messageObject.action === "accounts/relationships/"){
|
2022-12-01 13:00:18 +03:00
|
|
|
if (debug) console.log(JSON.stringify(messageObject))
|
2020-06-16 17:09:28 +03:00
|
|
|
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
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
switch (messageObject.key) {
|
|
|
|
case 'followers_count':
|
|
|
|
followers_count = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'following_count':
|
|
|
|
following_count = messageObject.data
|
|
|
|
break;
|
2020-06-18 19:40:24 +03:00
|
|
|
/* case 'acct':
|
|
|
|
username = messageObject.data
|
|
|
|
break; */
|
2020-05-29 21:05:05 +03:00
|
|
|
case 'created_at':
|
|
|
|
created_at = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'statuses_count':
|
|
|
|
statuses_count = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'note':
|
|
|
|
note = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'url':
|
|
|
|
url = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'following':
|
|
|
|
following = messageObject.data
|
|
|
|
followers_count = followers_count + (following ? 1 : - 1)
|
|
|
|
break;
|
|
|
|
case 'muting':
|
|
|
|
muting = messageObject.data
|
|
|
|
break;
|
|
|
|
case 'blocking':
|
|
|
|
blocking = messageObject.data
|
2020-06-18 19:40:24 +03:00
|
|
|
// followers_count = followers_count + (blocking ? -1 : 0)
|
2020-05-29 21:05:05 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-04 12:17:06 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
// The effective value will be restricted by ApplicationWindow.allowedOrientations
|
|
|
|
allowedOrientations: Orientation.All
|
|
|
|
Component.onCompleted: {
|
|
|
|
var msg
|
|
|
|
|
|
|
|
if (user_id) {
|
|
|
|
msg = {
|
|
|
|
'action' : "accounts/relationships/",
|
2020-06-16 17:09:28 +03:00
|
|
|
'params' : [ {name: "id", data: user_id} ],
|
2020-05-29 21:05:05 +03:00
|
|
|
'conf' : Logic.conf
|
|
|
|
}
|
|
|
|
worker.sendMessage(msg)
|
2020-06-16 17:09:28 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
} else {
|
|
|
|
var instance = Logic.conf['instance'].split("//")
|
|
|
|
msg = {
|
|
|
|
'action' : "accounts/search?limit=1&q="+username.replace("@"+instance[1], ""),
|
|
|
|
'conf' : Logic.conf
|
|
|
|
}
|
|
|
|
worker.sendMessage(msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MyList {
|
|
|
|
id: list
|
|
|
|
header: ProfileHeader {
|
|
|
|
id: profileHeader
|
|
|
|
title: display_name
|
|
|
|
description: username
|
|
|
|
image: profileImage
|
|
|
|
bg: profileBackground
|
|
|
|
}
|
|
|
|
clip: true
|
|
|
|
mdl: ListModel {}
|
|
|
|
type: "accounts/"+user_id+"/statuses"
|
|
|
|
vars: {}
|
|
|
|
conf: Logic.conf
|
2020-06-03 08:34:33 +03:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
bottom: profileExpander.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
|
2020-06-18 19:40:24 +03:00
|
|
|
// ProfilePage ExpandingSection
|
|
|
|
ExpandingSectionGroup {
|
2020-06-03 08:34:33 +03:00
|
|
|
id: profileExpander
|
2020-06-18 19:40:24 +03:00
|
|
|
anchors.bottom: parent.bottom
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
ExpandingSection {
|
|
|
|
id: expandingSection1
|
2020-06-10 17:11:42 +03:00
|
|
|
title:
|
|
|
|
//: If there's no good translation for "About", use "Details" (in details about profile).
|
|
|
|
qsTr("About")
|
2020-05-29 21:05:05 +03:00
|
|
|
content.sourceComponent: Column {
|
2020-06-04 12:17:06 +03:00
|
|
|
spacing: Theme.paddingLarge
|
2020-05-29 21:05:05 +03:00
|
|
|
|
2020-06-04 12:17:06 +03:00
|
|
|
Item {
|
2020-05-29 21:05:05 +03:00
|
|
|
id: txtContainer
|
2020-06-03 08:34:33 +03:00
|
|
|
width: parent.width
|
2020-06-18 19:40:24 +03:00
|
|
|
height: profilePage.isPortrait ? Math.min( txtNote.height, parent.height * 0.5 ) : Math.min( txtNote.height, parent.height * 0.2 )
|
2023-10-11 13:39:33 +03:00
|
|
|
/*visible: {
|
2020-06-04 12:17:06 +03:00
|
|
|
if ((note.text === "") || ( note.text === "<p></p>" )) {
|
2020-05-29 21:05:05 +03:00
|
|
|
false
|
|
|
|
} else {
|
|
|
|
true
|
|
|
|
}
|
2023-10-11 13:39:33 +03:00
|
|
|
}*/
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-06-03 12:52:07 +03:00
|
|
|
SilicaFlickable {
|
2020-05-29 21:05:05 +03:00
|
|
|
id: txtFlickable
|
2020-06-03 12:52:07 +03:00
|
|
|
contentWidth: parent.width
|
|
|
|
contentHeight: txtNote.height
|
2020-06-04 12:17:06 +03:00
|
|
|
anchors.fill: parent
|
2020-05-29 21:05:05 +03:00
|
|
|
clip: true
|
2020-06-04 12:17:06 +03:00
|
|
|
|
2020-06-03 08:34:33 +03:00
|
|
|
VerticalScrollDecorator {}
|
2020-05-29 21:05:05 +03:00
|
|
|
|
2020-06-04 12:17:06 +03:00
|
|
|
Label {
|
2020-05-29 21:05:05 +03:00
|
|
|
id: txtNote
|
|
|
|
text: note
|
|
|
|
textFormat: Text.StyledText
|
2020-07-03 11:45:30 +03:00
|
|
|
color: Theme.secondaryHighlightColor
|
2020-06-04 12:17:06 +03:00
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
2020-06-29 11:48:06 +03:00
|
|
|
linkColor: Theme.secondaryColor
|
2020-06-04 12:17:06 +03:00
|
|
|
wrapMode: Text.Wrap
|
2020-05-29 21:05:05 +03:00
|
|
|
width: parent.width - ( 2 * Theme.horizontalPageMargin )
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
onLinkActivated: {
|
|
|
|
var test = link.split("/")
|
2022-12-01 13:00:18 +03:00
|
|
|
if (debug) console.log(link)
|
|
|
|
if (debug) console.log(JSON.stringify(test))
|
|
|
|
if (debug) console.log(JSON.stringify(test.length))
|
2020-05-29 21:05:05 +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)
|
2020-06-04 12:17:06 +03:00
|
|
|
} else if (test.length === 4 && test[3][0] === "@" ) {
|
|
|
|
pageStack.pop(pageStack.find(function(page) {
|
|
|
|
var check = page.isFirstPage === true;
|
|
|
|
if (check)
|
|
|
|
page.onLinkActivated(link)
|
|
|
|
return check;
|
|
|
|
}));
|
2020-05-29 21:05:05 +03:00
|
|
|
} else {
|
|
|
|
Qt.openUrlExternally(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 12:17:06 +03:00
|
|
|
Item { // dummy item for spacing
|
|
|
|
height: Theme.paddingSmall
|
|
|
|
}
|
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
Row {
|
|
|
|
id: statsRow
|
|
|
|
spacing: Theme.paddingLarge
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.leftMargin: Theme.paddingLarge
|
|
|
|
anchors.rightMargin: Theme.paddingLarge
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-06-29 11:48:06 +03:00
|
|
|
Label {
|
2020-05-29 21:05:05 +03:00
|
|
|
id: txtFollowers
|
2020-06-16 17:09:28 +03:00
|
|
|
visible: true //followers_count ? true : false
|
2020-06-10 17:11:42 +03:00
|
|
|
text: followers_count+" "+
|
|
|
|
//: Will show as: "35 Followers"
|
|
|
|
qsTr("Followers")
|
2020-05-29 21:05:05 +03:00
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
2020-06-29 11:48:06 +03:00
|
|
|
color: Theme.primaryColor
|
2020-05-29 21:05:05 +03:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
}
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-06-29 11:48:06 +03:00
|
|
|
Label {
|
2020-05-29 21:05:05 +03:00
|
|
|
id: txtFollowing
|
2020-06-16 17:09:28 +03:00
|
|
|
visible: true //following_count ? true : false
|
2020-06-10 17:11:42 +03:00
|
|
|
text: following_count+" "+
|
|
|
|
//: Will show as: "23 Following"
|
|
|
|
qsTr("Following")
|
2020-05-29 21:05:05 +03:00
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
2020-06-29 11:48:06 +03:00
|
|
|
color: Theme.primaryColor
|
2020-05-29 21:05:05 +03:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
}
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-06-29 11:48:06 +03:00
|
|
|
Label {
|
2020-05-29 21:05:05 +03:00
|
|
|
id: txtStatuses
|
2020-06-16 17:09:28 +03:00
|
|
|
visible: true //statuses_count ? true : false
|
2020-06-10 17:11:42 +03:00
|
|
|
text: statuses_count+" "+
|
|
|
|
//: Will show as: "115 Statuses"
|
|
|
|
qsTr("Statuses")
|
2020-05-29 21:05:05 +03:00
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
2020-07-03 11:45:30 +03:00
|
|
|
color: pressed ? Theme.highlightColor : Theme.primaryColor
|
2020-05-29 21:05:05 +03:00
|
|
|
wrapMode: Text.Wrap
|
2020-06-29 11:48:06 +03:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: expandingSection1.expanded = false
|
|
|
|
}
|
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 12:17:06 +03:00
|
|
|
Item { // dummy item for spacing
|
|
|
|
height: Theme.paddingSmall
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ButtonLayout {
|
|
|
|
id: btnLayout
|
|
|
|
Button {
|
|
|
|
id: btnMention
|
|
|
|
preferredWidth: Theme.buttonWidthSmall
|
2020-06-15 14:29:01 +03:00
|
|
|
text: qsTr("Mention")
|
2020-05-29 21:05:05 +03:00
|
|
|
onClicked: {
|
|
|
|
pageStack.push(Qt.resolvedUrl("ConversationPage.qml"), {
|
2020-06-10 17:11:42 +03:00
|
|
|
headerTitle: qsTr("Mention"),
|
2020-05-29 21:05:05 +03:00
|
|
|
description: "@"+username,
|
|
|
|
type: "new"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: btnFollow
|
|
|
|
preferredWidth: Theme.buttonWidthSmall
|
2020-06-10 17:11:42 +03:00
|
|
|
text: (following ?
|
|
|
|
//: Is a button. Keep it as short as possible.
|
|
|
|
qsTr("Unfollow") : (requested ?
|
|
|
|
//: Is a button. Keep it as short as possible.
|
|
|
|
qsTr("Requested") :
|
|
|
|
//: Is a button. Keep it as short as possible.
|
|
|
|
qsTr("Follow")))
|
2020-05-29 21:05:05 +03:00
|
|
|
color: (following ? highlightColor : (requested ? palette.errorColor : palette.primaryColor))
|
|
|
|
onClicked: {
|
|
|
|
var msg = {
|
|
|
|
'method' : 'POST',
|
|
|
|
'params' : [],
|
|
|
|
'action' : "accounts/" + user_id + (following ? '/unfollow':'/follow'),
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
}
|
|
|
|
}
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
Button {
|
|
|
|
id: btnMute
|
|
|
|
preferredWidth: Theme.buttonWidthSmall
|
2020-06-10 17:11:42 +03:00
|
|
|
text: (muting ?
|
|
|
|
//: Is a button. Keep it as short as possible.
|
|
|
|
qsTr("Unmute") :
|
|
|
|
//: Is a button. Keep it as short as possible.
|
|
|
|
qsTr("Mute"))
|
2020-06-03 08:34:33 +03:00
|
|
|
color: (muting ? palette.errorColor : palette.primaryColor)
|
2020-05-29 21:05:05 +03:00
|
|
|
onClicked: {
|
|
|
|
var msg = {
|
|
|
|
'method' : 'POST',
|
|
|
|
'params' : [],
|
|
|
|
'action' : "accounts/" + user_id + (muting ? '/unmute':'/mute'),
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
worker.sendMessage(msg);
|
|
|
|
}
|
|
|
|
}
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
Button {
|
|
|
|
id: btnBlock
|
|
|
|
preferredWidth: Theme.buttonWidthSmall
|
2020-06-10 17:11:42 +03:00
|
|
|
text: (blocking ?
|
|
|
|
//: Is a button. Keep it as short as possible.
|
|
|
|
qsTr("Unblock") :
|
|
|
|
//: Is a button. Keep it as short as possible.
|
|
|
|
qsTr("Block") )
|
2020-05-29 21:05:05 +03:00
|
|
|
color: (blocking ? palette.errorColor : palette.primaryColor)
|
|
|
|
onClicked: {
|
|
|
|
var msg = {
|
|
|
|
'method' : 'POST',
|
|
|
|
'params' : [],
|
|
|
|
'action' : "accounts/" + user_id + (blocking ? '/unblock':'/block'),
|
|
|
|
'conf' : Logic.conf
|
2020-07-03 11:45:30 +03:00
|
|
|
}
|
|
|
|
worker.sendMessage(msg)
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 12:17:06 +03:00
|
|
|
Rectangle { // dummy item for spacing
|
|
|
|
height: Theme.paddingSmall
|
|
|
|
width: parent.width
|
|
|
|
opacity: 0
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|