parent
b3a9bff381
commit
73eb4fe8b1
|
@ -132,3 +132,6 @@ QtObject:
|
||||||
if(self.activeChannel.id == chat.id):
|
if(self.activeChannel.id == chat.id):
|
||||||
self.activeChannel.setChatItem(chat)
|
self.activeChannel.setChatItem(chat)
|
||||||
self.activeChannelChanged()
|
self.activeChannelChanged()
|
||||||
|
|
||||||
|
proc blockContact*(self: ChatsView, id: string): string {.slot.} =
|
||||||
|
return self.status.chat.blockContact(id)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import eventemitter, json
|
import eventemitter, json
|
||||||
import sequtils
|
import sequtils
|
||||||
import libstatus/chat as status_chat
|
import libstatus/chat as status_chat
|
||||||
|
import libstatus/core as libstatus_core
|
||||||
|
import ./profile as status_profile
|
||||||
import chronicles
|
import chronicles
|
||||||
import chat/[chat, message]
|
import chat/[chat, message]
|
||||||
import ../signals/messages
|
import ../signals/messages
|
||||||
|
@ -158,3 +160,9 @@ proc confirmJoiningGroup*(self: ChatModel, chatId: string) =
|
||||||
var response = parseJson(status_chat.confirmJoiningGroup(chatId))
|
var response = parseJson(status_chat.confirmJoiningGroup(chatId))
|
||||||
var (chats, messages) = formatChatUpdate(response)
|
var (chats, messages) = formatChatUpdate(response)
|
||||||
self.events.emit("pushMessage", PushMessageArgs(messages: messages, chats: chats))
|
self.events.emit("pushMessage", PushMessageArgs(messages: messages, chats: chats))
|
||||||
|
|
||||||
|
proc blockContact*(self: ChatModel, id: string): string =
|
||||||
|
var contact = status_profile.getContactByID(id)
|
||||||
|
contact.systemTags.add(":contact/blocked")
|
||||||
|
result = status_chat.blockContact(contact)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import strutils
|
||||||
import chronicles
|
import chronicles
|
||||||
import ../chat/[chat, message]
|
import ../chat/[chat, message]
|
||||||
import ../../signals/messages
|
import ../../signals/messages
|
||||||
|
import ../profile
|
||||||
|
|
||||||
proc buildFilter*(chatId: string, filterId: string = "", symKeyId: string = "", oneToOne: bool = false, identity: string = "", topic: string = "", discovery: bool = false, negotiated: bool = false, listen: bool = true):JsonNode =
|
proc buildFilter*(chatId: string, filterId: string = "", symKeyId: string = "", oneToOne: bool = false, identity: string = "", topic: string = "", discovery: bool = false, negotiated: bool = false, listen: bool = true):JsonNode =
|
||||||
result = %* {
|
result = %* {
|
||||||
|
@ -106,6 +107,19 @@ proc sendChatMessage*(chatId: string, msg: string): string =
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
proc blockContact*(contact: Profile): string =
|
||||||
|
callPrivateRPC("blockContact".prefix, %* [
|
||||||
|
{
|
||||||
|
"id": contact.id,
|
||||||
|
"ensVerified": contact.ensVerified,
|
||||||
|
"ensVerifiedAt": contact.ensVerifiedAt,
|
||||||
|
"ensVerificationRetries": contact.ensVerificationRetries,
|
||||||
|
"alias": contact.alias,
|
||||||
|
"identicon": contact.identicon,
|
||||||
|
"systemTags": contact.systemTags
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
proc markAllRead*(chatId: string): string =
|
proc markAllRead*(chatId: string): string =
|
||||||
callPrivateRPC("markAllRead".prefix, %* [chatId])
|
callPrivateRPC("markAllRead".prefix, %* [chatId])
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ type Profile* = ref object
|
||||||
id*, alias*, username*, identicon*: string
|
id*, alias*, username*, identicon*: string
|
||||||
ensVerified*: bool
|
ensVerified*: bool
|
||||||
ensVerifiedAt*: int
|
ensVerifiedAt*: int
|
||||||
ensVerificationEntries*: int
|
ensVerificationRetries*: int
|
||||||
|
systemTags*: seq[string]
|
||||||
|
|
||||||
proc toProfileModel*(account: Account): Profile =
|
proc toProfileModel*(account: Account): Profile =
|
||||||
result = Profile(
|
result = Profile(
|
||||||
|
@ -26,10 +27,15 @@ proc toProfileModel*(account: Account): Profile =
|
||||||
alias: account.name,
|
alias: account.name,
|
||||||
ensVerified: false,
|
ensVerified: false,
|
||||||
ensVerifiedAt: 0,
|
ensVerifiedAt: 0,
|
||||||
ensVerificationEntries: 0,
|
ensVerificationRetries: 0,
|
||||||
|
systemTags: @[]
|
||||||
)
|
)
|
||||||
|
|
||||||
proc toProfileModel*(profile: JsonNode): Profile =
|
proc toProfileModel*(profile: JsonNode): Profile =
|
||||||
|
var systemTags: seq[string] = @[]
|
||||||
|
if profile["systemTags"].kind != JNull:
|
||||||
|
systemTags = profile["systemTags"].to(seq[string])
|
||||||
|
|
||||||
result = Profile(
|
result = Profile(
|
||||||
id: profile["id"].str,
|
id: profile["id"].str,
|
||||||
username: profile["alias"].str,
|
username: profile["alias"].str,
|
||||||
|
@ -37,14 +43,13 @@ proc toProfileModel*(profile: JsonNode): Profile =
|
||||||
alias: profile["alias"].str,
|
alias: profile["alias"].str,
|
||||||
ensVerified: profile["ensVerified"].getBool,
|
ensVerified: profile["ensVerified"].getBool,
|
||||||
ensVerifiedAt: profile["ensVerifiedAt"].getInt,
|
ensVerifiedAt: profile["ensVerifiedAt"].getInt,
|
||||||
ensVerificationEntries: profile["ensVerificationEntries"].getInt
|
ensVerificationRetries: profile["ensVerificationRetries"].getInt,
|
||||||
|
systemTags: systemTags
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
proc getContactByID*(id: string): Profile =
|
proc getContactByID*(id: string): Profile =
|
||||||
let response = libstatus_core.getContactByID(id)
|
let response = libstatus_core.getContactByID(id)
|
||||||
let val = parseJSON($response)
|
result = toProfileModel(parseJSON($response)["result"])
|
||||||
result = toProfileModel(val)
|
|
||||||
|
|
||||||
type
|
type
|
||||||
ProfileModel* = ref object
|
ProfileModel* = ref object
|
||||||
|
|
|
@ -194,7 +194,29 @@ ModalPopup {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
footer: StyledButton {
|
footer: Item {
|
||||||
|
width: parent.width
|
||||||
|
height: children[0].height
|
||||||
|
|
||||||
|
StyledButton {
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: addToContactsButton.width + 32
|
||||||
|
btnColor: "white"
|
||||||
|
btnBorderWidth: 1
|
||||||
|
btnBorderColor: "#EEF2F5"
|
||||||
|
textColor: "#FF2D55"
|
||||||
|
label: "Block User"
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
onClicked: {
|
||||||
|
chatsModel.blockContact(fromAuthor)
|
||||||
|
// TODO(pascal): Change block user button state based
|
||||||
|
// on :contact/blocked state
|
||||||
|
profilePopup.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledButton {
|
||||||
|
id: addToContactsButton
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: Theme.smallPadding
|
anchors.rightMargin: Theme.smallPadding
|
||||||
label: "Add to contacts"
|
label: "Add to contacts"
|
||||||
|
@ -203,4 +225,5 @@ ModalPopup {
|
||||||
profilePopup.close()
|
profilePopup.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@ Popup {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.topMargin: Theme.padding
|
||||||
anchors.bottomMargin: Theme.padding
|
anchors.bottomMargin: Theme.padding
|
||||||
anchors.rightMargin: Theme.padding
|
anchors.rightMargin: Theme.padding
|
||||||
anchors.leftMargin: Theme.padding
|
anchors.leftMargin: Theme.padding
|
||||||
|
|
|
@ -8,6 +8,8 @@ import "../imports"
|
||||||
Button {
|
Button {
|
||||||
property string label: "My button"
|
property string label: "My button"
|
||||||
property color btnColor: Theme.lightBlue
|
property color btnColor: Theme.lightBlue
|
||||||
|
property color btnBorderColor: "transparent"
|
||||||
|
property int btnBorderWidth: 0
|
||||||
property color textColor: Theme.blue
|
property color textColor: Theme.blue
|
||||||
property bool disabled: false
|
property bool disabled: false
|
||||||
|
|
||||||
|
@ -20,6 +22,8 @@ Button {
|
||||||
color: disabled ? Theme.grey : btnStyled.btnColor
|
color: disabled ? Theme.grey : btnStyled.btnColor
|
||||||
radius: Theme.radius
|
radius: Theme.radius
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
border.color: btnBorderColor
|
||||||
|
border.width: btnBorderWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
|
Loading…
Reference in New Issue