parent
662d20b7ac
commit
28a4362b64
|
@ -29,10 +29,6 @@ proc handleChatEvents(self: ChatController) =
|
|||
let notifications = ActivityCenterNotificationsArgs(e).activityCenterNotifications
|
||||
self.view.pushActivityCenterNotifications(notifications)
|
||||
|
||||
self.status.events.on("contactBlocked") do(e: Args):
|
||||
var evArgs = ContactBlockedArgs(e)
|
||||
self.view.removeChat(evArgs.contact.address)
|
||||
|
||||
self.status.events.on("contactUpdate") do(e: Args):
|
||||
var evArgs = ContactUpdateArgs(e)
|
||||
self.view.updateUsernames(evArgs.contacts)
|
||||
|
|
|
@ -77,10 +77,13 @@ QtObject:
|
|||
self.contactList.updateContact(contact)
|
||||
if contact.systemTags.contains(contactAdded):
|
||||
self.addedContacts.updateContact(contact)
|
||||
|
||||
if contact.isBlocked():
|
||||
self.blockedContacts.updateContact(contact)
|
||||
|
||||
if contact.requestReceived() and not contact.systemTags.contains(contactAdded) and not contact.systemTags.contains(contactBlocked):
|
||||
self.contactRequests.updateContact(contact)
|
||||
|
||||
if not requestAlreadyAdded and contact.requestReceived():
|
||||
self.contactRequestAdded(status_ens.userNameOrAlias(contact), contact.address)
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@ type
|
|||
ContactUpdateArgs* = ref object of Args
|
||||
contacts*: seq[Profile]
|
||||
|
||||
ContactBlockedArgs* = ref object of Args
|
||||
contact*: Profile
|
||||
|
||||
proc newContactModel*(events: EventEmitter): ContactModel =
|
||||
result = ContactModel()
|
||||
result.events = events
|
||||
|
@ -34,12 +31,8 @@ proc getContactByID*(self: ContactModel, id: string): Profile =
|
|||
proc blockContact*(self: ContactModel, id: string): string =
|
||||
var contact = self.getContactByID(id)
|
||||
contact.systemTags.add(contactBlocked)
|
||||
let index = contact.systemTags.find(contactAdded)
|
||||
if (index > -1):
|
||||
contact.systemTags.delete(index)
|
||||
discard status_contacts.blockContact(contact)
|
||||
self.events.emit("contactBlocked", ContactBlockedArgs(contact: contact))
|
||||
|
||||
discard status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.alias, contact.identicon, contact.identityImage.thumbnail, contact.systemTags, contact.localNickname)
|
||||
self.events.emit("contactBlocked", Args())
|
||||
|
||||
proc unblockContact*(self: ContactModel, id: string): string =
|
||||
var contact = self.getContactByID(id)
|
||||
|
|
|
@ -7,18 +7,6 @@ var
|
|||
contactsInited {.threadvar.}: bool
|
||||
dirty: Atomic[bool]
|
||||
|
||||
# TODO: remove Profile from here
|
||||
proc blockContact*(contact: Profile): string =
|
||||
callPrivateRPC("blockContact".prefix, %* [
|
||||
{
|
||||
"id": contact.id,
|
||||
"ensVerified": contact.ensVerified,
|
||||
"alias": contact.alias,
|
||||
"identicon": contact.identicon,
|
||||
"systemTags": contact.systemTags
|
||||
}
|
||||
])
|
||||
|
||||
proc getContactByID*(id: string): string =
|
||||
result = callPrivateRPC("getContactByID".prefix, %* [id])
|
||||
dirty.store(true)
|
||||
|
|
|
@ -17,7 +17,7 @@ const contactBlocked* = ":contact/blocked"
|
|||
const contactRequest* = ":contact/request-received"
|
||||
|
||||
proc isContact*(self: Profile): bool =
|
||||
result = self.systemTags.contains(contactAdded) and not self.systemTags.contains(":contact/blocked")
|
||||
result = self.systemTags.contains(contactAdded)
|
||||
|
||||
proc isBlocked*(self: Profile): bool =
|
||||
result = self.systemTags.contains(contactBlocked)
|
||||
|
|
|
@ -299,6 +299,24 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: blockedBanner
|
||||
Layout.fillWidth: true
|
||||
height: 40
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
visible: isBlocked
|
||||
color: Style.current.red
|
||||
opacity: 0.1
|
||||
}
|
||||
|
||||
Text {
|
||||
id: blockedText
|
||||
anchors.centerIn: blockedBanner
|
||||
visible: isBlocked
|
||||
color: Style.current.red
|
||||
text: qsTr("Blocked")
|
||||
}
|
||||
|
||||
StackLayout {
|
||||
id: stackLayoutChatMessages
|
||||
Layout.fillWidth: true
|
||||
|
@ -324,6 +342,7 @@ Item {
|
|||
Connections {
|
||||
target: chatsModel.channelView
|
||||
onActiveChannelChanged: {
|
||||
isBlocked = profileModel.contacts.isContactBlocked(activeChatId);
|
||||
chatInput.suggestions.hide();
|
||||
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||
populateSuggestions();
|
||||
|
@ -400,7 +419,7 @@ Item {
|
|||
community.admin ||
|
||||
chatsModel.channelView.activeChannel.canPost
|
||||
}
|
||||
enabled: !isBlocked
|
||||
isContactBlocked: isBlocked
|
||||
chatInputPlaceholder: isBlocked ?
|
||||
//% "This user has been blocked."
|
||||
qsTrId("this-user-has-been-blocked-") :
|
||||
|
@ -443,6 +462,7 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ Item {
|
|||
community.admin ||
|
||||
chatsModel.channelView.activeChannel.canPost
|
||||
}
|
||||
enabled: !isBlocked
|
||||
isContactBlocked: isBlocked
|
||||
chatInputPlaceholder: isBlocked ?
|
||||
//% "This user has been blocked."
|
||||
qsTrId("this-user-has-been-blocked-") :
|
||||
|
|
|
@ -26,9 +26,9 @@ ScrollView {
|
|||
isVisible: {
|
||||
if (selectMode) {
|
||||
return !searchString || model.name.toLowerCase().includes(searchString)
|
||||
} else {
|
||||
return isChecked || isUser
|
||||
}
|
||||
|
||||
return isChecked || isUser
|
||||
}
|
||||
showCheckbox: root.selectMode
|
||||
pubKey: model.pubKey
|
||||
|
|
|
@ -14,6 +14,7 @@ ListView {
|
|||
property string searchString: ""
|
||||
property string lowerCaseSearchString: searchString.toLowerCase()
|
||||
property string contactToRemove: ""
|
||||
property bool hideBlocked: false
|
||||
|
||||
property Component profilePopupComponent: ProfilePopup {
|
||||
id: profilePopup
|
||||
|
@ -35,9 +36,15 @@ ListView {
|
|||
var popup = profilePopupComponent.createObject(contactList);
|
||||
popup.openPopup(showFooter, userName, fromAuthor, identicon, textParam, nickName);
|
||||
}
|
||||
visible: searchString === "" ||
|
||||
visible: {
|
||||
if (hideBlocked && model.isBlocked) {
|
||||
return false
|
||||
}
|
||||
|
||||
return searchString === "" ||
|
||||
model.name.toLowerCase().includes(lowerCaseSearchString) ||
|
||||
model.address.toLowerCase().includes(lowerCaseSearchString)
|
||||
}
|
||||
onBlockContactActionTriggered: {
|
||||
blockContactConfirmationDialog.contactName = name
|
||||
blockContactConfirmationDialog.contactAddress = address
|
||||
|
|
|
@ -219,6 +219,7 @@ Item {
|
|||
anchors.topMargin: Style.current.bigPadding
|
||||
anchors.bottom: parent.bottom
|
||||
contacts: profileModel.contacts.addedContacts
|
||||
hideBlocked: true
|
||||
searchString: searchBox.text
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,10 @@ StatusAppLayout {
|
|||
const contacts = []
|
||||
let contact
|
||||
for (let i = 0; i < nbContacts; i++) {
|
||||
if (profileModel.contacts.list.rowData(i, "isBlocked") === "true") {
|
||||
continue
|
||||
}
|
||||
|
||||
contact = {
|
||||
name: profileModel.contacts.list.rowData(i, "name"),
|
||||
localNickname: profileModel.contacts.list.rowData(i, "localNickname"),
|
||||
|
|
|
@ -20,15 +20,13 @@ ModalPopup {
|
|||
title: qsTrId("block-user")
|
||||
|
||||
StyledText {
|
||||
//% "Blocking will remove any messages you received from %1 and stop new messages from reaching you."
|
||||
text: qsTrId("blocking-will-remove-any-messages-you-received-from--1-and-stop-new-messages-from-reaching-you-").arg(contactName)
|
||||
text: qsTr("Blocking will stop new messages from reaching you from %1.").arg(contactName)
|
||||
font.pixelSize: 15
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
|
||||
footer: Item {
|
||||
id: footerContainer
|
||||
width: parent.width
|
||||
|
|
|
@ -46,7 +46,7 @@ Item {
|
|||
name: model.name
|
||||
address: model.address
|
||||
identicon: model.thumbnailImage || model.identicon
|
||||
visible: model.isContact && (root.filterText === "" ||
|
||||
visible: model.isContact && !model.isBlocked && (root.filterText === "" ||
|
||||
root.matchesAlias(model.name.toLowerCase(), root.filterText.toLowerCase()) ||
|
||||
model.name.toLowerCase().includes(root.filterText.toLowerCase()) ||
|
||||
model.address.toLowerCase().includes(root.filterText.toLowerCase())) &&
|
||||
|
|
|
@ -26,6 +26,7 @@ Rectangle {
|
|||
property bool isReply: false
|
||||
property bool isImage: false
|
||||
property bool isEdit: false
|
||||
property bool isContactBlocked: false
|
||||
|
||||
property var recentStickers
|
||||
property var stickerPackList
|
||||
|
@ -695,6 +696,7 @@ Rectangle {
|
|||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 16
|
||||
visible: !isEdit && control.chatType === Constants.chatTypeOneToOne && !control.isStatusUpdateInput
|
||||
enabled: !control.isContactBlocked
|
||||
onClicked: {
|
||||
highlighted = true
|
||||
chatCommandsPopup.open()
|
||||
|
@ -711,6 +713,7 @@ Rectangle {
|
|||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 16
|
||||
visible: !isEdit && control.chatType !== Constants.chatTypePublic && !control.isStatusUpdateInput
|
||||
enabled: !control.isContactBlocked
|
||||
|
||||
onClicked: {
|
||||
highlighted = true
|
||||
|
@ -720,6 +723,7 @@ Rectangle {
|
|||
|
||||
Rectangle {
|
||||
id: messageInput
|
||||
enabled: !control.isContactBlocked
|
||||
property int maxInputFieldHeight: control.isStatusUpdateInput ? 124 : 112
|
||||
property int defaultInputFieldHeight: control.isStatusUpdateInput ? 56 : 40
|
||||
anchors.left: imageBtn.visible ? imageBtn.right : parent.left
|
||||
|
@ -727,7 +731,7 @@ Rectangle {
|
|||
anchors.top: control.isStatusUpdateInput ? parent.top : undefined
|
||||
anchors.bottom: !control.isStatusUpdateInput ? parent.bottom : undefined
|
||||
anchors.bottomMargin: control.isStatusUpdateInput ? 0 : 12
|
||||
anchors.right: parent.right
|
||||
anchors.right: unblockBtn.visible ? unblockBtn.left : parent.right
|
||||
anchors.rightMargin: Style.current.smallPadding
|
||||
height: {
|
||||
if (messageInputField.implicitHeight <= messageInput.defaultInputFieldHeight) {
|
||||
|
@ -859,8 +863,7 @@ Rectangle {
|
|||
font.pixelSize: 15
|
||||
font.family: Style.current.fontRegular.name
|
||||
wrapMode: TextArea.Wrap
|
||||
//% "Type a message"
|
||||
placeholderText: qsTrId("type-a-message")
|
||||
placeholderText: control.chatInputPlaceholder
|
||||
placeholderTextColor: Style.current.secondaryText
|
||||
selectByMouse: true
|
||||
color: isEdit ? Theme.palette.directColor1 : Style.current.textColor
|
||||
|
@ -1110,4 +1113,20 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
id: unblockBtn
|
||||
visible: control.isContactBlocked
|
||||
height: messageInput.height - Style.current.halfPadding
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.current.halfPadding
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: Style.current.padding
|
||||
borderRadius: Style.current.radius
|
||||
text: qsTr("Unblock")
|
||||
type: "warn"
|
||||
onClicked: function (event) {
|
||||
profileModel.contacts.unblockContact(chatsModel.channelView.activeChannel.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue