chore: send emphemeral notification from QML side

This commit is contained in:
Mykhailo Prakhov 2024-03-06 19:19:12 +01:00 committed by Jonathan Rainville
parent 9b8c6aa673
commit 49f7accbc2
3 changed files with 34 additions and 13 deletions

View File

@ -1252,18 +1252,8 @@ method onMembershipStatusUpdated*[T](self: Module[T], communityId: string, membe
let item = self.view.model().getItemById(communityId)
if item.id != "":
item.updateMembershipStatus(memberPubkey, status)
case status:
of MembershipRequestState.Banned:
self.displayEphemeralNotification(fmt "{contactName} was banned from {communityDto.name}", "" , "checkmark-circle", false, EphemeralNotificationType.Success.int, "")
of MembershipRequestState.Kicked:
self.displayEphemeralNotification(fmt "{contactName} was kicked from {communityDto.name}", "" , "checkmark-circle", false, EphemeralNotificationType.Success.int, "")
of MembershipRequestState.Unbanned:
self.displayEphemeralNotification(fmt "{contactName} unbanned from {communityDto.name}", "" , "checkmark-circle", false, EphemeralNotificationType.Success.int, "")
else:
discard
if status == MembershipRequestState.Banned or status == MembershipRequestState.Kicked or status == MembershipRequestState.Unbanned:
self.view.emitCommunityMemberStatusEphemeralNotification(communityDto.name, contactName, status.int)
method calculateProfileSectionHasNotification*[T](self: Module[T]): bool =
return not self.controller.isMnemonicBackedUp()

View File

@ -353,4 +353,10 @@ QtObject:
self.delegate.addressWasShown(address)
proc onCheckIfAddressWasCopied*(self: View, value: string) {.slot.} =
self.delegate.checkIfAddressWasCopied(value)
self.delegate.checkIfAddressWasCopied(value)
proc communityMemberStatusEphemeralNotification*(self:View, communityName: string, memberName: string, membershipState: int) {.signal.}
proc emitCommunityMemberStatusEphemeralNotification*(self:View, communityName: string, memberName: string,
membershipState: int) =
self.communityMemberStatusEphemeralNotification(communityName, memberName, membershipState)

View File

@ -224,6 +224,31 @@ Item {
"%1/%2".arg(appMain.rootStore.getEtherscanLink(chainId)).arg(txHash))
}
}
function onCommunityMemberStatusEphemeralNotification(communityName: string, memberName: string, state: CommunityMembershipRequestState) {
var text = ""
switch (state) {
case Constants.CommunityMembershipRequestState.Banned:
text = qsTr("%1 was banned from %2").arg(memberName).arg(communityName)
break
case Constants.CommunityMembershipRequestState.Unbanned:
text = qsTr("%1 unbanned from %2").arg(memberName).arg(communityName)
break
case Constants.CommunityMembershipRequestState.Kicked:
text = qsTr("%1 was kicked from %2").arg(memberName).arg(communityName)
break
default: return
}
Global.displayToastMessage(
text,
"",
"checkmark-circle",
false,
Constants.ephemeralNotificationType.success,
""
)
}
}
QtObject {