feat: add muted states for channel

Fixes #1615
This commit is contained in:
Jonathan Rainville 2021-01-15 13:36:42 -05:00 committed by Iuri Matias
parent 8462c1c013
commit 76688733f5
7 changed files with 71 additions and 0 deletions

View File

@ -561,6 +561,18 @@ QtObject:
self.status.chat.unmuteChat(selectedChannel) self.status.chat.unmuteChat(selectedChannel)
self.chats.updateChat(selectedChannel) self.chats.updateChat(selectedChannel)
proc muteCurrentChannel*(self: ChatsView) {.slot.} =
self.activeChannel.mute()
let channel = self.chats.getChannelById(self.activeChannel.id())
channel.muted = true
self.chats.updateChat(channel)
proc unmuteCurrentChannel*(self: ChatsView) {.slot.} =
self.activeChannel.unmute()
let channel = self.chats.getChannelById(self.activeChannel.id())
channel.muted = false
self.chats.updateChat(channel)
proc channelIsMuted*(self: ChatsView, channelIndex: int): bool {.slot.} = proc channelIsMuted*(self: ChatsView, channelIndex: int): bool {.slot.} =
if (self.chats.chats.len == 0): return false if (self.chats.chats.len == 0): return false
let selectedChannel = self.chats.getChannel(channelIndex) let selectedChannel = self.chats.getChannel(channelIndex)

View File

@ -125,6 +125,15 @@ QtObject:
read = isMember read = isMember
notify = membershipChanged notify = membershipChanged
proc mutedChanged*(self: ChatItemView) {.signal.}
proc muted*(self: ChatItemView): bool {.slot.} =
return ?.self.chatItem.muted
QtProperty[bool] muted:
read = muted
notify = mutedChanged
proc contains*(self: ChatItemView, pubKey: string): bool {.slot.} = proc contains*(self: ChatItemView, pubKey: string): bool {.slot.} =
if self.chatItem.isNil: return false if self.chatItem.isNil: return false
return self.chatItem.contains(pubKey) return self.chatItem.contains(pubKey)
@ -132,3 +141,13 @@ QtObject:
proc isAdmin*(self: ChatItemView, pubKey: string): bool {.slot.} = proc isAdmin*(self: ChatItemView, pubKey: string): bool {.slot.} =
if self.chatItem.isNil: return false if self.chatItem.isNil: return false
return self.chatItem.isAdmin(pubKey) return self.chatItem.isAdmin(pubKey)
proc mute*(self: ChatItemView) {.slot.} =
self.status.chat.muteChat(self.chatItem)
self.chatItem.muted = true
self.mutedChanged()
proc unmute*(self: ChatItemView) {.slot.} =
self.status.chat.unmuteChat(self.chatItem)
self.chatItem.muted = false
self.mutedChanged()

View File

@ -32,6 +32,7 @@ Rectangle {
chatName: chatsModel.activeChannel.name chatName: chatsModel.activeChannel.name
chatType: chatsModel.activeChannel.chatType chatType: chatsModel.activeChannel.chatType
identicon: chatsModel.activeChannel.identicon identicon: chatsModel.activeChannel.identicon
muted: chatsModel.activeChannel.muted
identiconSize: 36 identiconSize: 36
onClicked: { onClicked: {
@ -55,6 +56,7 @@ Rectangle {
chatName: chatsModel.activeChannel.name chatName: chatsModel.activeChannel.name
chatType: chatsModel.activeChannel.chatType chatType: chatsModel.activeChannel.chatType
identicon: chatsModel.activeChannel.identicon identicon: chatsModel.activeChannel.identicon
muted: chatsModel.activeChannel.muted
} }
} }

View File

@ -83,6 +83,7 @@ Rectangle {
anchors.right: contactTime.left anchors.right: contactTime.left
anchors.rightMargin: Style.current.smallPadding anchors.rightMargin: Style.current.smallPadding
elide: Text.ElideRight elide: Text.ElideRight
color: muted ? Style.current.secondaryText : Style.current.textColor
font.weight: Font.Medium font.weight: Font.Medium
font.pixelSize: 15 font.pixelSize: 15
anchors.left: channelIcon.visible ? channelIcon.right : contactImage.right anchors.left: channelIcon.visible ? channelIcon.right : contactImage.right

View File

@ -0,0 +1,4 @@
<svg width="13" height="14" viewBox="0 0 13 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.95186 2.11736C8.16545 1.90377 8.14277 1.54794 7.87625 1.40578C7.38934 1.14607 6.83479 0.999998 6.25002 0.999998C4.52863 0.999998 3.0692 2.26576 2.82576 3.96984L2.39144 7.01005C2.36619 7.18684 2.68245 7.38677 2.80873 7.26049L7.95186 2.11736Z" fill="#939BA1"/>
<path d="M0.202001 11.9879C-0.0730994 12.282 -0.0672105 12.7434 0.219669 13.0303C0.512563 13.3232 0.987436 13.3232 1.28033 13.0303L3.16421 11.1464C3.25798 11.0527 3.38516 11 3.51777 11H3.75C4.02614 11 4.24359 11.2273 4.31171 11.4949C4.53197 12.3601 5.31626 13 6.25 13C7.18374 13 7.96803 12.3601 8.18829 11.4949C8.25641 11.2273 8.47386 11 8.75 11H10.8358C11.7267 11 12.1729 9.92286 11.5429 9.29289L10.9571 8.7071C10.4981 8.24811 10.2004 7.65264 10.1086 7.01005L9.79296 4.80054C9.7707 4.64475 9.8231 4.48756 9.93438 4.37628L12.2803 2.03033C12.5732 1.73744 12.5732 1.26256 12.2803 0.969668C11.9935 0.682807 11.532 0.676903 11.238 0.951949C11.2322 0.958112 11.2263 0.964201 11.2203 0.970214L0.220328 11.9702C0.214295 11.9762 0.208185 11.9822 0.202001 11.9879Z" fill="#939BA1"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,5 +1,6 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import "../../imports" import "../../imports"
import "../../shared" import "../../shared"
import "../../shared/status" import "../../shared/status"
@ -13,6 +14,7 @@ Item {
property string identicon property string identicon
property int identiconSize: 40 property int identiconSize: 40
property bool isCompact: false property bool isCompact: false
property bool muted: false
property string profileImage: chatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : "" property string profileImage: chatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : ""
@ -61,6 +63,35 @@ Item {
font.pixelSize: 15 font.pixelSize: 15
} }
SVGImage {
property bool hovered: false
id: bellImg
visible: root.muted
source: "../../app/img/bell-disabled.svg"
anchors.verticalCenter: chatName.verticalCenter
anchors.left: chatName.right
anchors.leftMargin: 4
width: 12.5
height: 12.5
ColorOverlay {
anchors.fill: parent
source: parent
color: bellImg.hovered ? Style.current.textColor : Style.current.darkGrey
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onEntered: bellImg.hovered = true
onExited: bellImg.hovered = false
onClicked: {
chatsModel.unmuteCurrentChannel()
}
}
}
Connections { Connections {
target: profileModel.contacts target: profileModel.contacts

View File

@ -13,6 +13,7 @@ Button {
property string identicon property string identicon
property int identiconSize: 40 property int identiconSize: 40
property bool isCompact: false property bool isCompact: false
property bool muted: false
implicitHeight: 48 implicitHeight: 48
implicitWidth: content.width + 8 implicitWidth: content.width + 8
@ -24,6 +25,7 @@ Button {
chatId: control.chatId chatId: control.chatId
chatName: control.chatName chatName: control.chatName
chatType: control.chatType chatType: control.chatType
muted: control.muted
identicon: { identicon: {
if (control.chatType === Constants.chatTypeOneToOne) { if (control.chatType === Constants.chatTypeOneToOne) {
return appMain.getProfileImage(control.chatId) || control.identicon return appMain.getProfileImage(control.chatId) || control.identicon