chore: remove public chat functionnalities

Fixes #8504

Removes the ability to create public chats, see public chats and even leaves previously active public chats
This commit is contained in:
Jonathan Rainville 2023-01-20 14:01:32 -05:00
parent 519f08241e
commit fdc0dce782
27 changed files with 31 additions and 305 deletions

View File

@ -112,13 +112,13 @@ proc searchMessages*(self: Controller, searchTerm: string) =
if (self.searchLocation != singletonInstance.userProfile.getPubKey()):
communities.add(self.searchLocation)
else:
let types = @[ChatType.OneToOne, ChatType.Public, ChatType.PrivateGroupChat]
let types = @[ChatType.OneToOne, ChatType.PrivateGroupChat]
let displayedChats = self.getChatDetailsForChatTypes(types)
for c in displayedChats:
chats.add(c.id)
if (communities.len == 0 and chats.len == 0):
let types = @[ChatType.OneToOne, ChatType.Public, ChatType.PrivateGroupChat]
let types = @[ChatType.OneToOne, ChatType.PrivateGroupChat]
let displayedChats = self.getChatDetailsForChatTypes(types)
for c in displayedChats:
chats.add(c.id)

View File

@ -12,7 +12,7 @@ import ../../../../../app_service/service/provider/service as provider_service
import ../../../../global/global_singleton
export io_interface
# Shouldn't be public ever, user only within this module.
# Shouldn't be public ever, use only within this module.
type TmpSendTransactionDetails = object
payloadMethod: string
requestType: string

View File

@ -86,21 +86,7 @@ proc init*(self: Controller) =
let chat = self.getChat()
# Events only for public chats
if chat.isPublicChat():
self.events.on(SIGNAL_MESSAGES_LOADED) do(e:Args):
let args = MessagesLoadedArgs(e)
if(self.chatId != args.chatId):
return
self.delegate.onNewMessagesLoaded(args.messages)
self.events.on(SIGNAL_NEW_MESSAGE_RECEIVED) do(e:Args):
let args = MessagesArgs(e)
if(self.chatId != args.chatId):
return
self.delegate.onNewMessagesLoaded(args.messages)
# Events only for the user list, so not needed in public and one to one chats
# Events only for the user list, so not needed in one to one chats
if(self.isUsersListAvailable):
self.events.on(SIGNAL_CONTACT_UNTRUSTWORTHY) do(e: Args):
var args = TrustArgs(e)

View File

@ -65,30 +65,6 @@ method viewDidLoad*(self: Module) =
method getModuleAsVariant*(self: Module): QVariant =
return self.viewVariant
method onNewMessagesLoaded*(self: Module, messages: seq[MessageDto]) =
for m in messages:
if(self.view.model().isContactWithIdAdded(m.`from`)):
continue
let contactDetails = self.controller.getContactDetails(m.`from`)
let statusUpdateDto = self.controller.getStatusForContact(m.`from`)
let status = toOnlineStatus(statusUpdateDto.statusType)
self.view.model().addItem(initMemberItem(
pubKey = m.`from`,
displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name,
localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias,
icon = contactDetails.icon,
colorId = contactDetails.colorId,
colorHash = contactDetails.colorHash,
onlineStatus = status,
isContact = contactDetails.details.isContact,
isVerified = contactDetails.details.isContactVerified(),
isUntrustworthy = contactDetails.details.trustStatus == TrustStatus.Untrustworthy,
)
)
method contactNicknameChanged*(self: Module, publicKey: string) =
let contactDetails = self.controller.getContactDetails(publicKey)
self.view.model().setName(

View File

@ -302,13 +302,6 @@ proc getOneToOneChatNameAndImage*(self: Controller, chatId: string):
tuple[name: string, image: string, largeImage: string] =
return self.chatService.getOneToOneChatNameAndImage(chatId)
proc createPublicChat*(self: Controller, chatId: string) =
let response = self.chatService.createPublicChat(chatId)
if(response.success):
self.delegate.addChatIfDontExist(response.chatDto, false, self.events, self.settingsService, self.nodeConfigurationService,
self.contactService, self.chatService, self.communityService, self.messageService,
self.gifService, self.mailserversService)
proc createOneToOneChat*(self: Controller, communityID: string, chatId: string, ensName: string) =
let response = self.chatService.createOneToOneChat(communityID, chatId, ensName)
if(response.success):

View File

@ -160,9 +160,6 @@ method isCommunity*(self: AccessInterface): bool {.base.} =
method getMySectionId*(self: AccessInterface): string {.base.} =
raise newException(ValueError, "No implementation available")
method createPublicChat*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")
method switchToOrCreateOneToOneChat*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -144,8 +144,7 @@ proc buildChatSectionUI(
var colorHash: ColorHashDto = @[]
var colorId: int = 0
var onlineStatus = OnlineStatus.Inactive
let isUsersListAvailable = (chatDto.chatType != ChatType.OneToOne and
chatDto.chatType != ChatType.Public)
let isUsersListAvailable = chatDto.chatType != ChatType.OneToOne
var blocked = false
let belongToCommunity = chatDto.communityId != ""
if(chatDto.chatType == ChatType.OneToOne):
@ -412,17 +411,6 @@ method onActiveSectionChange*(self: Module, sectionId: string) =
method chatsModel*(self: Module): chats_model.Model =
return self.view.chatsModel()
method createPublicChat*(self: Module, chatId: string) =
if(self.controller.isCommunity()):
debug "creating public chat is not allowed for community, most likely it's an error in qml", methodName="createPublicChat"
return
if(self.chatContentModules.hasKey(chatId)):
self.setActiveItemSubItem(chatId, "")
return
self.controller.createPublicChat(chatId)
method addNewChat*(
self: Module,
chatDto: ChatDto,
@ -788,8 +776,6 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI
var notificationTitle = contactDetails.defaultDisplayName
case chatDetails.chatType:
of ChatType.Public:
notificationTitle.add(fmt" ({chatDetails.name})")
of ChatType.PrivateGroupChat:
notificationTitle.add(fmt" ({chatDetails.name})")
of ChatType.CommunityChat:

View File

@ -141,9 +141,6 @@ QtObject:
return chatContentVariant
proc createPublicChat*(self: View, chatId: string) {.slot.} =
self.delegate.createPublicChat(chatId)
proc createOneToOneChat*(self: View, communityID: string, chatId: string, ensName: string) {.slot.} =
self.delegate.createOneToOneChat(communityID, chatId, ensName)

View File

@ -23,7 +23,7 @@ include ../../../../../app_service/common/json_utils
const cancelledRequest* = "cancelled"
# Shouldn't be public ever, user only within this module.
# Shouldn't be public ever, use only within this module.
type TmpSendEnsTransactionDetails = object
ensUsername: string
address: string

View File

@ -14,7 +14,7 @@ export io_interface
const cancelledRequest* = "cancelled"
# Shouldn't be public ever, user only within this module.
# Shouldn't be public ever, use only within this module.
type TmpBuyStickersTransactionDetails = object
packId: string
address: string

View File

@ -13,7 +13,7 @@ export io_interface
const cancelledRequest* = "cancelled"
# Shouldn't be public ever, user only within this module.
# Shouldn't be public ever, use only within this module.
type TmpSendTransactionDetails = object
fromAddr: string
toAddr: string

View File

@ -270,7 +270,11 @@ proc toChannelGroupDto*(jsonObj: JsonNode): ChannelGroupDto =
var chatsObj: JsonNode
if(jsonObj.getProp("chats", chatsObj)):
for _, chatObj in chatsObj:
result.chats.add(toChatDto(chatObj))
let chat = toChatDto(chatObj)
if (chat.chatType == ChatType.Public):
# Filter out public chats as we don't show them anymore
continue
result.chats.add(chat)
var categoriesObj: JsonNode
if(jsonObj.getProp("categories", categoriesObj)):
@ -307,9 +311,6 @@ proc toChatDto*(jsonObj: JsonNode, communityId: string): ChatDto =
if communityId != "":
result.id = communityId & result.id.replace(communityId, "") # Adding communityID prefix in case it's not available
proc isPublicChat*(chatDto: ChatDto): bool =
return chatDto.chatType == ChatType.Public
proc isOneToOneChat*(chatDto: ChatDto): bool =
return chatDto.chatType == ChatType.OneToOne

View File

@ -165,7 +165,11 @@ QtObject:
for chat in chats:
if chat.active and chat.chatType != chat_dto.ChatType.Unknown:
self.chats[chat.id] = chat
if chat.chatType == chat_dto.ChatType.Public:
# Deactivate old public chats
discard status_chat.deactivateChat(chat.id)
else:
self.chats[chat.id] = chat
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
@ -293,17 +297,6 @@ QtObject:
self.updateOrAddChat(result.chatDto)
result.success = true
proc createPublicChat*(self: Service, chatId: string): tuple[chatDto: ChatDto, success: bool] =
try:
let response = status_chat.createPublicChat(chatId)
result.chatDto = response.result.toChatDto()
self.updateOrAddChat(result.chatDto)
result.success = true
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
return
proc createOneToOneChat*(self: Service, communityID: string, chatId: string, ensName: string): tuple[chatDto: ChatDto, success: bool] =
try:
if self.hasChannel(chatId):

View File

@ -36,11 +36,6 @@ proc getChats*(): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* []
result = callPrivateRPC("chat_getChats", payload)
proc createPublicChat*(chatId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let communityId = ""
let payload = %* [communityId, chatId]
result = callPrivateRPC("chat_joinChat", payload)
proc createOneToOneChat*(chatId: string, ensName: string = ""): RpcResponse[JsonNode] {.raises: [Exception].} =
let communityId = ""
let payload = %* [communityId, chatId, ensName]

View File

@ -185,13 +185,6 @@ GridLayout {
type: StatusChatInfoButton.Type.GroupChat
}
StatusChatInfoButton {
title: "public-chat"
subTitle: "Public Chat"
asset.color: Theme.palette.miscColor7
type: StatusChatInfoButton.Type.PublicChat
}
StatusChatInfoButton {
title: "community-channel"
subTitle: "Community Chat"

View File

@ -134,24 +134,6 @@ StatusSectionLayout {
Layout.fillWidth: true
}
StatusRoundButton {
Layout.alignment: Qt.AlignVCenter
icon.name: "public-chat"
icon.color: Theme.palette.directColor1
icon.height: editBtn.icon.height
icon.width: editBtn.icon.width
implicitWidth: editBtn.implicitWidth
implicitHeight: editBtn.implicitHeight
type: StatusRoundButton.Type.Tertiary
StatusToolTip {
text: qsTr("Join public chats")
visible: parent.hovered
orientation: StatusToolTip.Orientation.Bottom
y: parent.height + 12
}
}
StatusIconTabButton {
id: editBtn
icon.name: "edit"

View File

@ -31,7 +31,7 @@ Rectangle {
charactersLen: root.type === StatusChatListItem.Type.OneToOneChat ? 2 : 1
}
property alias ringSettings: identicon.ringSettings
property int type: StatusChatListItem.Type.PublicChat
property int type: StatusChatListItem.Type.Unknown0
property bool highlighted: false
property bool highlightWhenCreated: false
property bool selected: false
@ -123,8 +123,6 @@ Rectangle {
icon: {
switch (root.type) {
case StatusChatListItem.Type.PublicChat:
return Theme.palette.name === "light" ? "tiny/public-chat" : "tiny/public-chat-white"
case StatusChatListItem.Type.GroupChat:
return Theme.palette.name === "light" ? "tiny/group" : "tiny/group-white"
case StatusChatListItem.Type.CommunityChat:
@ -144,10 +142,7 @@ Rectangle {
anchors.rightMargin: 6
anchors.verticalCenter: parent.verticalCenter
text: (root.type === StatusChatListItem.Type.PublicChat &&
!root.name.startsWith("#") ?
"#" + root.name :
root.name)
text: root.name
elide: Text.ElideRight
color: {
if (root.muted && !hoverHander.hovered && !root.highlighted) {

View File

@ -25,7 +25,7 @@ Button {
}
property alias ringSettings: identicon.ringSettings
property int type: StatusChatInfoButton.Type.PublicChat
property int type: StatusChatInfoButton.Type.Unknown0
property alias tooltip: statusToolTip
signal pinnedMessagesCountClicked(var mouse)
@ -101,9 +101,7 @@ Button {
objectName: "statusChatInfoButtonNameText"
Layout.fillWidth: true
elide: Text.ElideRight
text: root.type === StatusChatInfoButton.Type.PublicChat && !root.title.startsWith("#") ?
"#" + root.title
: root.title
text: root.title
color: root.muted ? Theme.palette.directColor5 : Theme.palette.directColor1
font.weight: Font.Medium
}

View File

@ -1,115 +0,0 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import utils 1.0
import shared.controls 1.0
import StatusQ.Core 0.1
import StatusQ.Controls 0.1
import StatusQ.Controls.Validators 0.1
import shared.panels 1.0
import shared.popups 1.0
import "../helpers/channelList.js" as ChannelJSON
import "../panels"
// TODO: replace with StatusModal
ModalPopup {
signal joinPublicChat(string name)
signal suggestedMessageClicked(string channel)
function validate() {
channelName.validate(true)
return channelName.valid
}
function doJoin() {
if (!validate()) {
return
}
popup.joinPublicChat(channelName.text);
popup.close();
}
id: popup
title: qsTr("Join public chat")
onOpened: {
channelName.text = "";
channelName.input.edit.forceActiveFocus(Qt.MouseFocusReason)
}
contentWrapper.anchors.bottomMargin: 0
Row {
id: description
Layout.fillHeight: false
Layout.fillWidth: true
width: parent.width
StyledText {
width: parent.width
font.pixelSize: 15
text: qsTr("A public chat is where you get to hang out with others, make friends and talk about subjects of your interest.")
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignTop
}
}
StatusInput {
id: channelName
input.edit.objectName: "joinPublicChannelInput"
anchors.top: description.bottom
anchors.topMargin: Style.current.padding
placeholderText: qsTr("chat-name")
charLimit: 24
Keys.onEnterPressed: doJoin()
Keys.onReturnPressed: doJoin()
input.asset.name: "channel"
validators: [StatusMinLengthValidator {
minLength: 1
errorMessage: qsTr("You need to enter a channel name")
},
StatusValidator {
name: "validChannelNameValidator"
validate: function (t) { return Utils.isValidChannelName(t) }
errorMessage: qsTr("The channel name can only contain lowercase letters, numbers and dashes")
}]
validationMode: StatusInput.ValidationMode.OnlyWhenDirty
}
StatusScrollView {
id: sview
anchors.top: channelName.bottom
anchors.topMargin: Style.current.smallPadding
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
contentHeight: {
var totalHeight = 0
for (let i = 0; i < sectionRepeater.count; i++) {
totalHeight += sectionRepeater.itemAt(i).height + Style.current.padding
}
return totalHeight + Style.current.padding
}
SuggestedChannelsPanel {
id: sectionRepeater
width: sview.width
onSuggestedMessageClicked: {
popup.suggestedMessageClicked(channel);
}
}
}
footer: StatusButton {
objectName: "startChatButton"
anchors.bottom: parent.bottom
anchors.right: parent.right
onClicked : doJoin()
text: qsTr("Start chat")
}
}

View File

@ -88,7 +88,7 @@ Item {
StatusFlatRoundButton {
id: membersButton
visible: {
if(!chatContentModule || chatContentModule.chatDetails.type === Constants.chatType.publicChat)
if(!chatContentModule)
return false
return localAccountSensitiveSettings.showOnlineUsers &&
@ -278,10 +278,8 @@ Item {
return ""
// In some moment in future this should be part of the backend logic.
// (once we add transaltion on the backend side)
// (once we add translation on the backend side)
switch (chatContentModule.chatDetails.type) {
case Constants.chatType.publicChat:
return qsTr("Public chat")
case Constants.chatType.privateGroupChat:
return qsTr("%n member(s)", "", chatContentModule.usersModule.model.count)
case Constants.chatType.communityChat:
@ -330,8 +328,7 @@ Item {
if(!chatContentModule)
return false
return chatContentModule.chatDetails.type !== Constants.chatType.publicChat &&
chatContentModule.chatDetails.type !== Constants.chatType.communityChat &&
return chatContentModule.chatDetails.type !== Constants.chatType.communityChat &&
chatContentModule.chatDetails.type !== Constants.chatType.privateGroupChat
}
onClicked: {

View File

@ -102,10 +102,7 @@ StatusSectionLayout {
}
let chatContentModule = root.rootStore.currentChatContentModule()
if (!chatContentModule
|| chatContentModule.chatDetails.type === Constants.chatType.publicChat)
{
// New communities have no chats, so no chatContentModule or it is a public chat
if (!chatContentModule) {
return false
}
// Check if user list is available as an option for particular chat content module

View File

@ -64,26 +64,6 @@ Item {
Layout.fillWidth: true
}
StatusRoundButton {
Layout.alignment: Qt.AlignVCenter
icon.name: "public-chat"
icon.color: Theme.palette.directColor1
icon.height: startChatButton.icon.height
icon.width: startChatButton.icon.width
implicitWidth: startChatButton.implicitWidth
implicitHeight: startChatButton.implicitHeight
type: StatusRoundButton.Type.Tertiary
onClicked: Global.openPopup(publicChatPopupComponent)
StatusToolTip {
text: qsTr("Join public chats")
visible: parent.hovered
orientation: StatusToolTip.Orientation.Bottom
y: parent.height + 12
}
}
StatusIconTabButton {
id: startChatButton
Layout.alignment: Qt.AlignVCenter
@ -243,23 +223,6 @@ Item {
}
}
Component {
id: publicChatPopupComponent
PublicChatPopup {
onJoinPublicChat: {
chatSectionModule.createPublicChat(name)
close()
}
onSuggestedMessageClicked: {
chatSectionModule.createPublicChat(channel)
close()
}
onClosed: {
destroy()
}
}
}
Component {
id: communitiesPopupComponent
CommunitiesPopup {

View File

@ -47,8 +47,7 @@ Badge {
StatusIcon {
Layout.preferredWidth: 16
Layout.preferredHeight: 16
icon: chatType === Constants.chatType.publicChat ? "tiny/public-chat"
: "tiny/group"
icon: "tiny/group"
color: Theme.palette.baseColor1
}
@ -60,9 +59,7 @@ Badge {
StyledText {
Layout.alignment: Qt.AlignVCenter
text: chatType !== Constants.chatType.publicChat ?
StatusQUtils.Emoji.parse(StatusQUtils.Utils.filterXSS(name)) :
"#" + StatusQUtils.Utils.filterXSS(name)
text: StatusQUtils.Emoji.parse(StatusQUtils.Utils.filterXSS(name))
color: Theme.palette.baseColor1
font.weight: Font.Medium

View File

@ -1,3 +0,0 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.66663 8.92905C1.66663 7.64467 2.63986 6.56926 3.91787 6.44146L6.94809 6.13843C8.96573 5.93667 10.9296 5.36842 12.7433 4.4616L15.9213 2.87259C17.0294 2.31851 18.3333 3.12433 18.3333 4.3633V13.9699C18.3333 15.2088 17.0294 16.0147 15.9213 15.4606L12.7433 13.8716C12.2307 13.6153 11.7061 13.386 11.1717 13.1844C10.9049 13.0838 10.625 13.2845 10.625 13.5696V15.4167C10.625 16.4522 9.78549 17.2917 8.74996 17.2917H8.33329C6.6074 17.2917 5.20829 15.8925 5.20829 14.1667V12.3978C5.20829 12.1838 5.04609 12.0045 4.83309 11.9832L3.91787 11.8917C2.63986 11.7639 1.66663 10.6885 1.66663 9.40411V8.92905ZM17.0833 4.3633V13.9699C17.0833 14.2796 16.7573 14.4811 16.4803 14.3425L13.3023 12.7535C11.3526 11.7787 9.24143 11.1678 7.07247 10.9509L4.04225 10.6479C3.40324 10.584 2.91663 10.0463 2.91663 9.40411V8.92905C2.91663 8.28686 3.40324 7.74915 4.04225 7.68525L7.07247 7.38223C9.24143 7.16534 11.3526 6.55446 13.3023 5.57964L16.4803 3.99063C16.7573 3.85211 17.0833 4.05357 17.0833 4.3633ZM6.91642 12.1916C6.67113 12.167 6.45829 12.3596 6.45829 12.6062V14.1667C6.45829 15.2022 7.29776 16.0417 8.33329 16.0417H8.74996C9.09514 16.0417 9.37496 15.7618 9.37496 15.4167V12.9449C9.37496 12.7541 9.24551 12.5871 9.05967 12.544C8.36533 12.3828 7.66005 12.2659 6.94809 12.1947L6.91642 12.1916Z" fill="#4360DF"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1062,7 +1062,7 @@ Rectangle {
Layout.bottomMargin: 4
icon.name: "image"
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
visible: !isEdit && control.chatType !== Constants.chatType.publicChat
visible: !isEdit
enabled: !control.isContactBlocked
onClicked: {
highlighted = true

View File

@ -15,7 +15,7 @@ Rectangle {
property string chatId: ""
property string name: "channelName"
property string message: "My latest message\n with a return"
property int chatType: Constants.chatType.publicChat
property int chatType: Constants.chatType.unknown
color: "#F7F7F7"
width: 366

View File

@ -29,7 +29,7 @@ StatusMenu {
property string selectedUserDisplayName: ""
property string selectedUserIcon: ""
property int chatType: Constants.chatType.publicChat
property int chatType: Constants.chatType.unknown
property string messageId: ""
property string unparsedText: ""
property string messageSenderId: ""
@ -411,8 +411,6 @@ StatusMenu {
return true
switch (root.chatType) {
case Constants.chatType.publicChat:
return false
case Constants.chatType.profile:
return false
case Constants.chatType.oneToOne: