2021-10-01 15:58:36 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
|
|
|
|
import utils 1.0
|
2022-03-22 08:29:58 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
2022-01-04 12:06:05 +00:00
|
|
|
|
2022-07-26 18:46:07 +00:00
|
|
|
property string locale: localAppSettings.language
|
2022-07-01 11:24:32 +00:00
|
|
|
|
2022-02-14 12:18:25 +00:00
|
|
|
property var contactsStore
|
2022-03-22 08:29:58 +00:00
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
property bool openCreateChat: false
|
2022-03-22 08:29:58 +00:00
|
|
|
property string createChatInitMessage: ""
|
|
|
|
property var createChatFileUrls: []
|
|
|
|
property bool createChatStartSendTransactionProcess: false
|
|
|
|
property bool createChatStartReceiveTransactionProcess: false
|
|
|
|
property string createChatStickerHashId: ""
|
|
|
|
property string createChatStickerPackId: ""
|
2022-08-10 19:18:20 +00:00
|
|
|
property string createChatStickerUrl: ""
|
2022-03-22 08:29:58 +00:00
|
|
|
|
2022-05-10 16:04:25 +00:00
|
|
|
property var membershipRequestPopup
|
2022-03-25 11:33:30 +00:00
|
|
|
property var contactsModel: root.contactsStore.myContactsModel
|
2022-03-22 08:29:58 +00:00
|
|
|
|
2022-01-04 12:06:05 +00:00
|
|
|
// Important:
|
|
|
|
// Each `ChatLayout` has its own chatCommunitySectionModule
|
|
|
|
// (on the backend chat and community sections share the same module since they are actually the same)
|
|
|
|
property var chatCommunitySectionModule
|
|
|
|
// Since qml component doesn't follow encaptulation from the backend side, we're introducing
|
|
|
|
// a method which will return appropriate chat content module for selected chat/channel
|
|
|
|
function currentChatContentModule(){
|
|
|
|
// When we decide to have the same struct as it's on the backend we will remove this function.
|
|
|
|
// So far this is a way to deal with refactord backend from the current qml structure.
|
|
|
|
if(chatCommunitySectionModule.activeItem.isSubItemActive)
|
|
|
|
chatCommunitySectionModule.prepareChatContentModuleForChatId(chatCommunitySectionModule.activeItem.activeSubItem.id)
|
|
|
|
else
|
|
|
|
chatCommunitySectionModule.prepareChatContentModuleForChatId(chatCommunitySectionModule.activeItem.id)
|
|
|
|
|
|
|
|
return chatCommunitySectionModule.getChatContentModule()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Contact requests related part
|
|
|
|
property var contactRequestsModel: chatCommunitySectionModule.contactRequestsModel
|
|
|
|
|
2022-02-07 21:55:14 +00:00
|
|
|
property var loadingHistoryMessagesInProgress: chatCommunitySectionModule.loadingHistoryMessagesInProgress
|
|
|
|
|
2022-04-08 10:41:35 +00:00
|
|
|
property var advancedModule: profileSectionModule.advancedModule
|
|
|
|
|
2022-01-25 20:07:03 +00:00
|
|
|
function setActiveCommunity(communityId) {
|
|
|
|
mainModule.setActiveSectionById(communityId);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setObservedCommunity(communityId) {
|
|
|
|
communitiesModuleInst.setObservedCommunity(communityId);
|
|
|
|
}
|
|
|
|
|
2022-02-09 17:35:59 +00:00
|
|
|
function getMySectionId() {
|
|
|
|
return chatCommunitySectionModule.getMySectionId()
|
|
|
|
}
|
|
|
|
|
2022-01-04 12:06:05 +00:00
|
|
|
function acceptContactRequest(pubKey) {
|
|
|
|
chatCommunitySectionModule.acceptContactRequest(pubKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
function acceptAllContactRequests() {
|
|
|
|
chatCommunitySectionModule.acceptAllContactRequests()
|
|
|
|
}
|
|
|
|
|
2022-05-27 08:57:18 +00:00
|
|
|
function dismissContactRequest(pubKey) {
|
|
|
|
chatCommunitySectionModule.dismissContactRequest(pubKey)
|
2022-01-04 12:06:05 +00:00
|
|
|
}
|
|
|
|
|
2022-05-27 08:57:18 +00:00
|
|
|
function dismissAllContactRequests() {
|
|
|
|
chatCommunitySectionModule.dismissAllContactRequests()
|
2022-01-04 12:06:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function blockContact(pubKey) {
|
|
|
|
chatCommunitySectionModule.blockContact(pubKey)
|
|
|
|
}
|
|
|
|
|
2022-03-22 08:29:58 +00:00
|
|
|
function interpretMessage(msg) {
|
|
|
|
if (msg.startsWith("/shrug")) {
|
|
|
|
return msg.replace("/shrug", "") + " ¯\\\\\\_(ツ)\\_/¯"
|
|
|
|
}
|
|
|
|
if (msg.startsWith("/tableflip")) {
|
|
|
|
return msg.replace("/tableflip", "") + " (╯°□°)╯︵ ┻━┻"
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendMessage(event, text, replyMessageId, fileUrls) {
|
|
|
|
var chatContentModule = currentChatContentModule()
|
|
|
|
if (fileUrls.length > 0){
|
|
|
|
chatContentModule.inputAreaModule.sendImages(JSON.stringify(fileUrls));
|
|
|
|
}
|
|
|
|
let msg = globalUtils.plainText(StatusQUtils.Emoji.deparse(text))
|
|
|
|
if (msg.length > 0) {
|
|
|
|
msg = interpretMessage(msg)
|
|
|
|
|
|
|
|
chatContentModule.inputAreaModule.sendMessage(
|
|
|
|
msg,
|
|
|
|
replyMessageId,
|
|
|
|
Utils.isOnlyEmoji(msg) ? Constants.messageContentType.emojiType : Constants.messageContentType.messageType,
|
|
|
|
false)
|
|
|
|
|
|
|
|
if (event)
|
|
|
|
event.accepted = true
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-01-04 12:06:05 +00:00
|
|
|
|
2022-01-13 21:41:43 +00:00
|
|
|
property var messageStore: MessageStore { }
|
|
|
|
|
2022-01-05 15:50:03 +00:00
|
|
|
property var emojiReactionsModel
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2022-01-13 10:16:11 +00:00
|
|
|
property var globalUtilsInst: globalUtils
|
|
|
|
|
2022-01-05 15:11:26 +00:00
|
|
|
property var mainModuleInst: mainModule
|
2021-12-13 19:52:55 +00:00
|
|
|
property var activityCenterModuleInst: activityCenterModule
|
2022-09-15 16:34:41 +00:00
|
|
|
property var activityCenterList: activityCenterModuleInst.activityNotificationsModel
|
2022-07-26 14:23:45 +00:00
|
|
|
property int unreadNotificationsCount: activityCenterList.unreadCount
|
2021-11-15 15:15:21 +00:00
|
|
|
|
2022-09-15 16:34:41 +00:00
|
|
|
function loadMoreNotifications() {
|
|
|
|
activityCenterModuleInst.loadMoreNotifications()
|
|
|
|
}
|
|
|
|
|
2021-12-14 19:21:50 +00:00
|
|
|
property var communitiesModuleInst: communitiesModule
|
|
|
|
property var communitiesList: communitiesModuleInst.model
|
2022-06-09 15:27:14 +00:00
|
|
|
property bool communityPermissionsEnabled: localAccountSensitiveSettings.isCommunityPermissionsEnabled
|
2021-12-14 19:21:50 +00:00
|
|
|
|
2021-11-22 11:08:09 +00:00
|
|
|
property var userProfileInst: userProfile
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2021-11-15 12:36:22 +00:00
|
|
|
property var accounts: walletSectionAccounts.model
|
|
|
|
property var currentAccount: walletSectionCurrent
|
2022-02-09 00:04:49 +00:00
|
|
|
|
|
|
|
property string currentCurrency: walletSection.currentCurrency
|
|
|
|
property string signingPhrase: walletSection.signingPhrase
|
|
|
|
|
2022-05-16 15:02:03 +00:00
|
|
|
property string channelEmoji: chatCommunitySectionModule && chatCommunitySectionModule.emoji ? chatCommunitySectionModule.emoji : ""
|
2022-03-14 19:32:52 +00:00
|
|
|
|
2021-11-30 10:50:53 +00:00
|
|
|
property ListModel addToGroupContacts: ListModel {}
|
|
|
|
|
2022-02-09 00:04:49 +00:00
|
|
|
property var walletSectionTransactionsInst: walletSectionTransactions
|
|
|
|
|
2022-04-08 10:41:35 +00:00
|
|
|
property bool isCommunityHistoryArchiveSupportEnabled: advancedModule? advancedModule.isCommunityHistoryArchiveSupportEnabled : false
|
|
|
|
|
2022-06-09 14:59:54 +00:00
|
|
|
property string communityTags: communitiesModule.tags
|
|
|
|
|
2021-11-25 17:12:19 +00:00
|
|
|
property var stickersModuleInst: stickersModule
|
2021-11-15 15:15:21 +00:00
|
|
|
|
2022-02-14 23:27:23 +00:00
|
|
|
property var stickersStore: StickersStore {
|
|
|
|
stickersModule: stickersModuleInst
|
|
|
|
}
|
|
|
|
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// property var activeCommunity: chatsModelInst.communities.activeCommunity
|
2021-11-15 15:15:21 +00:00
|
|
|
|
2022-04-07 07:44:49 +00:00
|
|
|
function getBadgeDetails(sectionId, chatId) {
|
|
|
|
try {
|
|
|
|
const jsonObj = root.activityCenterModuleInst.getDetails(sectionId, chatId)
|
|
|
|
let obj = JSON.parse(jsonObj)
|
|
|
|
return obj
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
return {
|
|
|
|
sType: "",
|
|
|
|
sName: "",
|
|
|
|
sImage: "",
|
|
|
|
sColor: "",
|
|
|
|
cName: "",
|
|
|
|
cImage: "",
|
|
|
|
cColor: "",
|
|
|
|
cEmoji: ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 19:18:20 +00:00
|
|
|
function sendSticker(channelId, hash, replyTo, pack, url) {
|
|
|
|
stickersModuleInst.send(channelId, hash, replyTo, pack, url)
|
2021-12-22 14:55:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 00:41:54 +00:00
|
|
|
function copyToClipboard(text) {
|
2022-01-13 10:16:11 +00:00
|
|
|
globalUtilsInst.copyToClipboard(text)
|
2021-10-21 00:41:54 +00:00
|
|
|
}
|
|
|
|
|
2022-03-28 22:16:56 +00:00
|
|
|
function copyImageToClipboardByUrl(content) {
|
|
|
|
globalUtilsInst.copyImageToClipboardByUrl(content)
|
2022-01-19 15:59:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-28 22:16:56 +00:00
|
|
|
function downloadImageByUrl(url, path) {
|
|
|
|
globalUtilsInst.downloadImageByUrl(url, path)
|
2022-01-19 15:59:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
function isCurrentUser(pubkey) {
|
|
|
|
return userProfileInst.pubKey === pubkey
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayName(name, pubkey) {
|
|
|
|
return isCurrentUser(pubkey) ? qsTr("You") : name
|
|
|
|
}
|
|
|
|
|
2021-10-21 00:41:54 +00:00
|
|
|
function getCommunity(communityId) {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// try {
|
|
|
|
// const communityJson = chatsModelInst.communities.list.getCommunityByIdJson(communityId);
|
|
|
|
// if (!communityJson) {
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// let community = JSON.parse(communityJson);
|
|
|
|
// if (community) {
|
|
|
|
// community.nbMembers = community.members.length;
|
|
|
|
// }
|
|
|
|
// return community
|
|
|
|
// } catch (e) {
|
|
|
|
// console.error("Error parsing community", e);
|
|
|
|
// }
|
2021-10-21 00:41:54 +00:00
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2021-10-22 20:49:47 +00:00
|
|
|
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
property var activeCommunityChatsModel: "" //chatsModelInst.communities.activeCommunity.chats
|
2021-10-22 20:49:47 +00:00
|
|
|
|
2022-06-02 17:48:10 +00:00
|
|
|
function createCommunity(args = {
|
|
|
|
name: "",
|
|
|
|
description: "",
|
|
|
|
introMessage: "",
|
|
|
|
outroMessage: "",
|
|
|
|
color: "",
|
2022-06-09 14:59:54 +00:00
|
|
|
tags: "",
|
2022-06-02 17:48:10 +00:00
|
|
|
image: {
|
|
|
|
src: "",
|
|
|
|
AX: 0,
|
|
|
|
AY: 0,
|
|
|
|
BX: 0,
|
|
|
|
BY: 0,
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
historyArchiveSupportEnabled: false,
|
|
|
|
checkedMembership: false,
|
|
|
|
pinMessagesAllowedForMembers: false
|
2022-08-17 12:44:53 +00:00
|
|
|
},
|
|
|
|
bannerJsonStr: ""
|
2022-06-02 17:48:10 +00:00
|
|
|
}) {
|
|
|
|
return communitiesModuleInst.createCommunity(
|
2022-06-09 14:59:54 +00:00
|
|
|
args.name, args.description, args.introMessage, args.outroMessage,
|
|
|
|
args.options.checkedMembership, args.color, args.tags,
|
2022-06-02 17:48:10 +00:00
|
|
|
args.image.src, args.image.AX, args.image.AY, args.image.BX, args.image.BY,
|
2022-08-17 12:44:53 +00:00
|
|
|
args.options.historyArchiveSupportEnabled, args.options.pinMessagesAllowedForMembers, args.bannerJsonStr);
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
2022-02-02 17:54:28 +00:00
|
|
|
|
|
|
|
function importCommunity(communityKey) {
|
|
|
|
root.communitiesModuleInst.importCommunity(communityKey);
|
|
|
|
}
|
2021-10-22 20:49:47 +00:00
|
|
|
|
2022-01-25 20:39:20 +00:00
|
|
|
function createCommunityCategory(categoryName, channels) {
|
|
|
|
chatCommunitySectionModule.createCommunityCategory(categoryName, channels)
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
|
|
|
|
2022-02-01 15:31:05 +00:00
|
|
|
function editCommunityCategory(categoryId, categoryName, channels) {
|
|
|
|
chatCommunitySectionModule.editCommunityCategory(categoryId, categoryName, channels);
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteCommunityCategory(categoryId) {
|
2022-02-01 00:32:53 +00:00
|
|
|
chatCommunitySectionModule.deleteCommunityCategory(categoryId);
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
|
|
|
|
2022-02-01 15:31:05 +00:00
|
|
|
function prepareEditCategoryModel(categoryId) {
|
|
|
|
chatCommunitySectionModule.prepareEditCategoryModel(categoryId);
|
2022-02-09 09:43:23 +00:00
|
|
|
}
|
2022-02-01 15:31:05 +00:00
|
|
|
|
2022-01-18 20:54:14 +00:00
|
|
|
function leaveCommunity() {
|
|
|
|
chatCommunitySectionModule.leaveCommunity();
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
|
|
|
|
2022-02-24 21:19:11 +00:00
|
|
|
function removeUserFromCommunity(pubKey) {
|
|
|
|
chatCommunitySectionModule.removeUserFromCommunity(pubKey);
|
|
|
|
}
|
|
|
|
|
2022-04-07 14:49:38 +00:00
|
|
|
function banUserFromCommunity(pubKey) {
|
|
|
|
chatCommunitySectionModule.banUserFromCommunity(pubKey);
|
|
|
|
}
|
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
function unbanUserFromCommunity(pubKey) {
|
|
|
|
chatCommunitySectionModule.unbanUserFromCommunity(pubKey);
|
|
|
|
}
|
|
|
|
|
2022-03-10 19:28:37 +00:00
|
|
|
function createCommunityChannel(channelName, channelDescription, channelEmoji, channelColor,
|
|
|
|
categoryId) {
|
|
|
|
chatCommunitySectionModule.createCommunityChannel(channelName, channelDescription,
|
|
|
|
channelEmoji, channelColor, categoryId);
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
|
|
|
|
2022-03-10 19:28:37 +00:00
|
|
|
function editCommunityChannel(chatId, newName, newDescription, newEmoji, newColor,
|
|
|
|
newCategory, channelPosition) {
|
2022-02-24 21:38:32 +00:00
|
|
|
chatCommunitySectionModule.editCommunityChannel(
|
|
|
|
chatId,
|
|
|
|
newName,
|
|
|
|
newDescription,
|
2022-03-07 14:56:05 +00:00
|
|
|
newEmoji,
|
2022-03-10 19:28:37 +00:00
|
|
|
newColor,
|
2022-02-24 21:38:32 +00:00
|
|
|
newCategory,
|
|
|
|
channelPosition
|
|
|
|
)
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 20:54:14 +00:00
|
|
|
function acceptRequestToJoinCommunity(requestId) {
|
|
|
|
chatCommunitySectionModule.acceptRequestToJoinCommunity(requestId)
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 20:54:14 +00:00
|
|
|
function declineRequestToJoinCommunity(requestId) {
|
|
|
|
chatCommunitySectionModule.declineRequestToJoinCommunity(requestId)
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
2021-10-28 20:23:30 +00:00
|
|
|
|
|
|
|
function userNameOrAlias(pk) {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// return chatsModelInst.userNameOrAlias(pk);
|
2021-10-28 20:23:30 +00:00
|
|
|
}
|
|
|
|
|
2022-01-21 19:18:56 +00:00
|
|
|
function generateAlias(pk) {
|
|
|
|
return globalUtils.generateAlias(pk);
|
2022-01-11 21:53:18 +00:00
|
|
|
}
|
|
|
|
|
2022-01-17 18:46:46 +00:00
|
|
|
function plainText(text) {
|
|
|
|
return globalUtils.plainText(text)
|
|
|
|
}
|
2022-01-18 17:20:31 +00:00
|
|
|
|
2022-01-25 12:09:27 +00:00
|
|
|
function removeCommunityChat(chatId) {
|
|
|
|
chatCommunitySectionModule.removeCommunityChat(chatId)
|
2022-01-18 17:20:31 +00:00
|
|
|
}
|
2022-01-25 14:51:38 +00:00
|
|
|
|
2022-02-11 21:41:34 +00:00
|
|
|
function reorderCommunityCategories(categoryId, to) {
|
2022-01-25 14:51:38 +00:00
|
|
|
chatCommunitySectionModule.reorderCommunityCategories(categoryId, to)
|
|
|
|
}
|
|
|
|
|
2022-02-11 21:41:34 +00:00
|
|
|
function reorderCommunityChat(categoryId, chatId, to) {
|
2022-01-25 14:51:38 +00:00
|
|
|
chatCommunitySectionModule.reorderCommunityChat(categoryId, chatId, to)
|
|
|
|
}
|
2022-02-11 21:41:34 +00:00
|
|
|
|
2022-05-31 11:16:11 +00:00
|
|
|
function joinCommunity(id, ensName) {
|
|
|
|
return communitiesModuleInst.joinCommunity(id, ensName)
|
2022-02-11 21:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function requestToJoinCommunity(id, ensName) {
|
|
|
|
return communitiesModuleInst.requestToJoinCommunity(id, ensName)
|
|
|
|
}
|
|
|
|
|
|
|
|
function userCanJoin(id) {
|
|
|
|
return communitiesModuleInst.userCanJoin(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
function isUserMemberOfCommunity(id) {
|
|
|
|
return communitiesModuleInst.isUserMemberOfCommunity(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
function isCommunityRequestPending(id) {
|
|
|
|
return communitiesModuleInst.isCommunityRequestPending(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSectionNameById(id) {
|
|
|
|
return communitiesList.getSectionNameById(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSectionByIdJson(id) {
|
|
|
|
return communitiesList.getSectionByIdJson(id)
|
|
|
|
}
|
|
|
|
|
2022-06-20 11:39:40 +00:00
|
|
|
function requestCommunityInfo(id) {
|
|
|
|
communitiesModuleInst.requestCommunityInfo(id)
|
|
|
|
}
|
|
|
|
|
2022-02-11 21:41:34 +00:00
|
|
|
function getLinkTitleAndCb(link) {
|
|
|
|
const result = {
|
|
|
|
title: "Status",
|
|
|
|
callback: null
|
|
|
|
}
|
|
|
|
|
|
|
|
// Link to send a direct message
|
|
|
|
let index = link.indexOf("/u/")
|
|
|
|
if (index === -1) {
|
|
|
|
// Try /p/ as well
|
|
|
|
index = link.indexOf("/p/")
|
|
|
|
}
|
|
|
|
if (index > -1) {
|
|
|
|
const pk = link.substring(index + 3)
|
2022-04-04 11:26:30 +00:00
|
|
|
result.title = qsTr("Start a 1-on-1 chat with %1")
|
2022-02-11 21:41:34 +00:00
|
|
|
.arg(isChatKey(pk) ? globalUtils.generateAlias(pk) : ("@" + removeStatusEns(pk)))
|
|
|
|
result.callback = function () {
|
|
|
|
if (isChatKey(pk)) {
|
2022-02-15 21:00:05 +00:00
|
|
|
chatCommunitySectionModule.createOneToOneChat("", pk, "")
|
2022-02-11 21:41:34 +00:00
|
|
|
} else {
|
|
|
|
// Not Refactored Yet
|
|
|
|
// chatsModel.channelView.joinWithENS(pk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
// Community
|
|
|
|
index = link.lastIndexOf("/c/")
|
|
|
|
if (index > -1) {
|
|
|
|
const communityId = link.substring(index + 3)
|
|
|
|
|
|
|
|
const communityName = getSectionNameById(communityId)
|
|
|
|
|
|
|
|
if (!communityName) {
|
|
|
|
// Unknown community, fetch the info if possible
|
|
|
|
communitiesModuleInst.requestCommunityInfo(communityId)
|
|
|
|
result.communityId = communityId
|
|
|
|
result.fetching = true
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2022-04-04 11:26:30 +00:00
|
|
|
result.title = qsTr("Join the %1 community").arg(communityName)
|
2022-02-11 21:41:34 +00:00
|
|
|
result.communityId = communityId
|
|
|
|
result.callback = function () {
|
|
|
|
const isUserMemberOfCommunity = isUserMemberOfCommunity(communityId)
|
|
|
|
if (isUserMemberOfCommunity) {
|
|
|
|
setActiveCommunity(communityId)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const userCanJoin = userCanJoin(communityId)
|
|
|
|
// TODO find what to do when you can't join
|
|
|
|
if (userCanJoin) {
|
2022-05-31 11:16:11 +00:00
|
|
|
joinCommunity(communityId, userProfileInst.ensName)
|
2022-02-11 21:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
// Group chat
|
|
|
|
index = link.lastIndexOf("/g/")
|
|
|
|
if (index > -1) {
|
|
|
|
let indexAdminPk = link.lastIndexOf("a=")
|
|
|
|
let indexChatName = link.lastIndexOf("a1=")
|
|
|
|
let indexChatId = link.lastIndexOf("a2=")
|
|
|
|
const pubKey = link.substring(indexAdminPk + 2, indexChatName - 1)
|
|
|
|
const chatName = link.substring(indexChatName + 3, indexChatId - 1)
|
|
|
|
const chatId = link.substring(indexChatId + 3, link.length)
|
2022-04-04 11:26:30 +00:00
|
|
|
result.title = qsTr("Join the %1 group chat").arg(chatName)
|
2022-02-11 21:41:34 +00:00
|
|
|
result.callback = function () {
|
|
|
|
// Not Refactored Yet
|
|
|
|
// chatsModel.groups.joinGroupChatFromInvitation(chatName, chatId, pubKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not Refactored Yet (when we get to this we will most likely remove it, since other approach will be used)
|
|
|
|
// // Public chat
|
|
|
|
// // This needs to be the last check because it is as VERY loose check
|
|
|
|
// index = link.lastIndexOf("/")
|
|
|
|
// if (index > -1) {
|
|
|
|
// const chatId = link.substring(index + 1)
|
2022-04-04 11:26:30 +00:00
|
|
|
// result.title = qsTr("Join the %1 public channel").arg(chatId)
|
2022-02-11 21:41:34 +00:00
|
|
|
// result.callback = function () {
|
|
|
|
// chatsModel.channelView.joinPublicChat(chatId);
|
|
|
|
// }
|
|
|
|
// return result
|
|
|
|
// }
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLinkDataForStatusLinks(link) {
|
|
|
|
if (!link.includes(Constants.deepLinkPrefix) && !link.includes(Constants.joinStatusLink)) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const result = getLinkTitleAndCb(link)
|
|
|
|
|
|
|
|
return {
|
|
|
|
site: "https://join.status.im",
|
|
|
|
title: result.title,
|
|
|
|
communityId: result.communityId,
|
|
|
|
fetching: result.fetching,
|
|
|
|
thumbnailUrl: Style.png("status"),
|
|
|
|
contentType: "",
|
|
|
|
height: 0,
|
|
|
|
width: 0,
|
|
|
|
callback: result.callback
|
|
|
|
}
|
|
|
|
}
|
2022-02-09 00:04:49 +00:00
|
|
|
|
|
|
|
function getPubkey() {
|
|
|
|
return userProfile.getPubKey()
|
|
|
|
}
|
|
|
|
|
2022-07-01 11:24:32 +00:00
|
|
|
property var allNetworks: networksModule.all
|
|
|
|
|
|
|
|
property var disabledChainIds: []
|
|
|
|
|
|
|
|
function addRemoveDisabledChain(suggestedRoutes, chainID, isDisbaled) {
|
|
|
|
if(isDisbaled) {
|
|
|
|
for(var i = 0; i < suggestedRoutes.length;i++) {
|
|
|
|
if(suggestedRoutes[i].chainId === chainID) {
|
|
|
|
disabledChainIds.push(suggestedRoutes[i].chainId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for(var i = 0; i < disabledChainIds.length;i++) {
|
|
|
|
if(disabledChainIds[i] === chainID) {
|
|
|
|
disabledChainIds.splice(i, 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkIfDisabledByUser(chainID) {
|
|
|
|
for(var i = 0; i < disabledChainIds.length;i++) {
|
|
|
|
if(disabledChainIds[i] === chainID) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-02-09 00:04:49 +00:00
|
|
|
function getFiatValue(balance, cryptoSymbo, fiatSymbol) {
|
|
|
|
return profileSectionModule.ensUsernamesModule.getFiatValue(balance, cryptoSymbo, fiatSymbol)
|
|
|
|
}
|
|
|
|
|
|
|
|
function acceptRequestTransaction(transactionHash, messageId, signature) {
|
|
|
|
return currentChatContentModule().inputAreaModule.acceptRequestTransaction(transactionHash, messageId, signature)
|
|
|
|
}
|
|
|
|
|
|
|
|
function acceptAddressRequest(messageId, address) {
|
|
|
|
currentChatContentModule().inputAreaModule.acceptAddressRequest(messageId, address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function declineAddressRequest(messageId) {
|
|
|
|
currentChatContentModule().inputAreaModule.declineAddressRequest(messageId)
|
|
|
|
}
|
|
|
|
|
|
|
|
function declineRequest(messageId) {
|
|
|
|
currentChatContentModule().inputAreaModule.declineRequest(messageId)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getGasEthValue(gweiValue, gasLimit) {
|
|
|
|
return profileSectionModule.ensUsernamesModule.getGasEthValue(gweiValue, gasLimit)
|
|
|
|
}
|
|
|
|
|
2022-05-19 08:53:57 +00:00
|
|
|
function estimateGas(from_addr, to, assetSymbol, value, chainId, data) {
|
|
|
|
return walletSectionTransactions.estimateGas(from_addr, to, assetSymbol, value === "" ? "0.00" : value, chainId, data)
|
2022-02-09 00:04:49 +00:00
|
|
|
}
|
|
|
|
|
2022-05-19 08:53:57 +00:00
|
|
|
function transfer(from, to, address, tokenSymbol, amount, gasLimit, gasPrice, tipLimit, overallLimit, password, chainId, uuid, eip1559Enabled) {
|
|
|
|
return walletSectionTransactions.transfer(
|
|
|
|
from, to, address, tokenSymbol, amount, gasLimit,
|
|
|
|
gasPrice, tipLimit, overallLimit, password, chainId, uuid,
|
|
|
|
eip1559Enabled
|
|
|
|
);
|
2022-02-09 00:04:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getAccountNameByAddress(address) {
|
|
|
|
return walletSectionAccounts.getAccountNameByAddress(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAccountIconColorByAddress(address) {
|
|
|
|
return walletSectionAccounts.getAccountIconColorByAddress(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAccountAssetsByAddress(address) {
|
|
|
|
walletSectionAccounts.setAddressForAssets(address)
|
|
|
|
return walletSectionAccounts.getAccountAssetsByAddress()
|
|
|
|
}
|
|
|
|
|
2022-05-19 08:53:57 +00:00
|
|
|
function suggestedFees(chainId) {
|
|
|
|
return JSON.parse(walletSectionTransactions.suggestedFees(chainId))
|
2022-02-14 23:27:23 +00:00
|
|
|
}
|
|
|
|
|
2022-07-01 11:24:32 +00:00
|
|
|
function suggestedRoutes(account, amount, token, disabledChainIds) {
|
|
|
|
return JSON.parse(walletSectionTransactions.suggestedRoutes(account, amount, token, disabledChainIds)).networks
|
2022-02-14 23:27:23 +00:00
|
|
|
}
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|