2021-10-01 18:58:36 +03:00
|
|
|
import QtQuick 2.13
|
|
|
|
|
|
|
|
import utils 1.0
|
2022-03-22 09:29:58 +01:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2022-10-17 12:17:25 +02:00
|
|
|
import shared.stores 1.0
|
2021-10-01 18:58:36 +03:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
2022-01-04 13:06:05 +01:00
|
|
|
|
2022-07-26 20:46:07 +02:00
|
|
|
property string locale: localAppSettings.language
|
2022-07-01 13:24:32 +02:00
|
|
|
|
2022-02-14 15:18:25 +03:00
|
|
|
property var contactsStore
|
2022-03-22 09:29:58 +01:00
|
|
|
|
2022-02-15 23:00:05 +02:00
|
|
|
property bool openCreateChat: false
|
2022-03-22 09:29:58 +01:00
|
|
|
property string createChatInitMessage: ""
|
|
|
|
property var createChatFileUrls: []
|
|
|
|
property bool createChatStartSendTransactionProcess: false
|
|
|
|
property bool createChatStartReceiveTransactionProcess: false
|
|
|
|
property string createChatStickerHashId: ""
|
|
|
|
property string createChatStickerPackId: ""
|
2022-08-10 15:18:20 -04:00
|
|
|
property string createChatStickerUrl: ""
|
2022-03-22 09:29:58 +01:00
|
|
|
|
2022-05-10 19:04:25 +03:00
|
|
|
property var membershipRequestPopup
|
2022-03-25 12:33:30 +01:00
|
|
|
property var contactsModel: root.contactsStore.myContactsModel
|
2022-03-22 09:29:58 +01:00
|
|
|
|
2022-01-04 13:06:05 +01: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 17:55:14 -04:00
|
|
|
property var loadingHistoryMessagesInProgress: chatCommunitySectionModule.loadingHistoryMessagesInProgress
|
|
|
|
|
2022-04-08 12:41:35 +02:00
|
|
|
property var advancedModule: profileSectionModule.advancedModule
|
|
|
|
|
2022-01-25 15:07:03 -05:00
|
|
|
function setActiveCommunity(communityId) {
|
|
|
|
mainModule.setActiveSectionById(communityId);
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:05:10 +02:00
|
|
|
function activateStatusDeepLink(link) {
|
|
|
|
mainModuleInst.activateStatusDeepLink(link)
|
|
|
|
}
|
|
|
|
|
2022-01-25 15:07:03 -05:00
|
|
|
function setObservedCommunity(communityId) {
|
|
|
|
communitiesModuleInst.setObservedCommunity(communityId);
|
|
|
|
}
|
|
|
|
|
2022-02-09 18:35:59 +01:00
|
|
|
function getMySectionId() {
|
|
|
|
return chatCommunitySectionModule.getMySectionId()
|
|
|
|
}
|
|
|
|
|
2022-11-08 09:36:08 +01:00
|
|
|
function amIChatAdmin() {
|
|
|
|
return currentChatContentModule().amIChatAdmin()
|
|
|
|
}
|
|
|
|
|
2022-01-04 13:06:05 +01:00
|
|
|
function acceptContactRequest(pubKey) {
|
|
|
|
chatCommunitySectionModule.acceptContactRequest(pubKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
function acceptAllContactRequests() {
|
|
|
|
chatCommunitySectionModule.acceptAllContactRequests()
|
|
|
|
}
|
|
|
|
|
2022-05-27 11:57:18 +03:00
|
|
|
function dismissContactRequest(pubKey) {
|
|
|
|
chatCommunitySectionModule.dismissContactRequest(pubKey)
|
2022-01-04 13:06:05 +01:00
|
|
|
}
|
|
|
|
|
2022-05-27 11:57:18 +03:00
|
|
|
function dismissAllContactRequests() {
|
|
|
|
chatCommunitySectionModule.dismissAllContactRequests()
|
2022-01-04 13:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function blockContact(pubKey) {
|
|
|
|
chatCommunitySectionModule.blockContact(pubKey)
|
|
|
|
}
|
|
|
|
|
2022-03-22 09:29:58 +01:00
|
|
|
function interpretMessage(msg) {
|
|
|
|
if (msg.startsWith("/shrug")) {
|
|
|
|
return msg.replace("/shrug", "") + " ¯\\\\\\_(ツ)\\_/¯"
|
|
|
|
}
|
|
|
|
if (msg.startsWith("/tableflip")) {
|
|
|
|
return msg.replace("/tableflip", "") + " (╯°□°)╯︵ ┻━┻"
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg
|
|
|
|
}
|
|
|
|
|
2022-11-25 15:08:12 +01:00
|
|
|
function sendMessage(event, text, replyMessageId, fileUrlsAndSources) {
|
2022-03-22 09:29:58 +01:00
|
|
|
var chatContentModule = currentChatContentModule()
|
2022-11-25 15:08:12 +01:00
|
|
|
if (fileUrlsAndSources.length > 0){
|
|
|
|
chatContentModule.inputAreaModule.sendImages(JSON.stringify(fileUrlsAndSources));
|
2022-03-22 09:29:58 +01:00
|
|
|
}
|
2022-11-25 15:08:12 +01:00
|
|
|
|
2022-03-22 09:29:58 +01:00
|
|
|
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 13:06:05 +01:00
|
|
|
|
2022-01-13 23:41:43 +02:00
|
|
|
property var messageStore: MessageStore { }
|
|
|
|
|
2022-01-05 16:50:03 +01:00
|
|
|
property var emojiReactionsModel
|
2021-10-01 18:58:36 +03:00
|
|
|
|
2022-01-13 11:16:11 +01:00
|
|
|
property var globalUtilsInst: globalUtils
|
|
|
|
|
2022-01-05 10:11:26 -05:00
|
|
|
property var mainModuleInst: mainModule
|
2022-09-15 19:34:41 +03:00
|
|
|
|
2021-12-14 14:21:50 -05:00
|
|
|
property var communitiesModuleInst: communitiesModule
|
|
|
|
property var communitiesList: communitiesModuleInst.model
|
2022-06-09 17:27:14 +02:00
|
|
|
property bool communityPermissionsEnabled: localAccountSensitiveSettings.isCommunityPermissionsEnabled
|
2021-12-14 14:21:50 -05:00
|
|
|
|
2021-11-22 12:08:09 +01:00
|
|
|
property var userProfileInst: userProfile
|
2021-10-01 18:58:36 +03:00
|
|
|
|
2022-02-09 01:04:49 +01:00
|
|
|
property string signingPhrase: walletSection.signingPhrase
|
|
|
|
|
2022-05-16 18:02:03 +03:00
|
|
|
property string channelEmoji: chatCommunitySectionModule && chatCommunitySectionModule.emoji ? chatCommunitySectionModule.emoji : ""
|
2022-03-14 15:32:52 -04:00
|
|
|
|
2021-11-30 11:50:53 +01:00
|
|
|
property ListModel addToGroupContacts: ListModel {}
|
|
|
|
|
2022-02-09 01:04:49 +01:00
|
|
|
property var walletSectionTransactionsInst: walletSectionTransactions
|
|
|
|
|
2022-04-08 12:41:35 +02:00
|
|
|
property bool isCommunityHistoryArchiveSupportEnabled: advancedModule? advancedModule.isCommunityHistoryArchiveSupportEnabled : false
|
|
|
|
|
2022-06-09 17:59:54 +03:00
|
|
|
property string communityTags: communitiesModule.tags
|
|
|
|
|
2021-11-25 12:12:19 -05:00
|
|
|
property var stickersModuleInst: stickersModule
|
2021-11-15 10:15:21 -05:00
|
|
|
|
2022-02-14 19:27:23 -04:00
|
|
|
property var stickersStore: StickersStore {
|
|
|
|
stickersModule: stickersModuleInst
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:18:20 -04:00
|
|
|
function sendSticker(channelId, hash, replyTo, pack, url) {
|
|
|
|
stickersModuleInst.send(channelId, hash, replyTo, pack, url)
|
2021-12-22 09:55:13 -05:00
|
|
|
}
|
|
|
|
|
2021-10-21 03:41:54 +03:00
|
|
|
function copyToClipboard(text) {
|
2022-01-13 11:16:11 +01:00
|
|
|
globalUtilsInst.copyToClipboard(text)
|
2021-10-21 03:41:54 +03:00
|
|
|
}
|
|
|
|
|
2022-03-29 00:16:56 +02:00
|
|
|
function copyImageToClipboardByUrl(content) {
|
|
|
|
globalUtilsInst.copyImageToClipboardByUrl(content)
|
2022-01-19 10:59:08 -05:00
|
|
|
}
|
|
|
|
|
2022-03-29 00:16:56 +02:00
|
|
|
function downloadImageByUrl(url, path) {
|
|
|
|
globalUtilsInst.downloadImageByUrl(url, path)
|
2022-01-19 10:59:08 -05:00
|
|
|
}
|
|
|
|
|
2022-03-09 11:27:32 +01:00
|
|
|
function isCurrentUser(pubkey) {
|
|
|
|
return userProfileInst.pubKey === pubkey
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayName(name, pubkey) {
|
|
|
|
return isCurrentUser(pubkey) ? qsTr("You") : name
|
|
|
|
}
|
|
|
|
|
2021-10-21 03:41:54 +03:00
|
|
|
function getCommunity(communityId) {
|
2021-12-13 15:24:21 +01: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 03:41:54 +03:00
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2021-10-22 23:49:47 +03:00
|
|
|
|
2021-12-13 15:24:21 +01:00
|
|
|
// Not Refactored Yet
|
|
|
|
property var activeCommunityChatsModel: "" //chatsModelInst.communities.activeCommunity.chats
|
2021-10-22 23:49:47 +03:00
|
|
|
|
2022-06-02 19:48:10 +02:00
|
|
|
function createCommunity(args = {
|
|
|
|
name: "",
|
|
|
|
description: "",
|
|
|
|
introMessage: "",
|
|
|
|
outroMessage: "",
|
|
|
|
color: "",
|
2022-06-09 17:59:54 +03:00
|
|
|
tags: "",
|
2022-06-02 19:48:10 +02:00
|
|
|
image: {
|
|
|
|
src: "",
|
|
|
|
AX: 0,
|
|
|
|
AY: 0,
|
|
|
|
BX: 0,
|
|
|
|
BY: 0,
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
historyArchiveSupportEnabled: false,
|
|
|
|
checkedMembership: false,
|
2022-10-07 12:33:23 -04:00
|
|
|
pinMessagesAllowedForMembers: false,
|
|
|
|
encrypted: false
|
2022-08-17 14:44:53 +02:00
|
|
|
},
|
|
|
|
bannerJsonStr: ""
|
2022-06-02 19:48:10 +02:00
|
|
|
}) {
|
|
|
|
return communitiesModuleInst.createCommunity(
|
2022-06-09 17:59:54 +03:00
|
|
|
args.name, args.description, args.introMessage, args.outroMessage,
|
|
|
|
args.options.checkedMembership, args.color, args.tags,
|
2022-06-02 19:48:10 +02:00
|
|
|
args.image.src, args.image.AX, args.image.AY, args.image.BX, args.image.BY,
|
2022-10-07 12:33:23 -04:00
|
|
|
args.options.historyArchiveSupportEnabled, args.options.pinMessagesAllowedForMembers,
|
|
|
|
args.bannerJsonStr, args.options.encrypted);
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
2022-02-02 18:54:28 +01:00
|
|
|
|
|
|
|
function importCommunity(communityKey) {
|
|
|
|
root.communitiesModuleInst.importCommunity(communityKey);
|
|
|
|
}
|
2021-10-22 23:49:47 +03:00
|
|
|
|
2022-01-25 23:39:20 +03:00
|
|
|
function createCommunityCategory(categoryName, channels) {
|
|
|
|
chatCommunitySectionModule.createCommunityCategory(categoryName, channels)
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
|
|
|
|
2022-02-01 11:31:05 -04:00
|
|
|
function editCommunityCategory(categoryId, categoryName, channels) {
|
|
|
|
chatCommunitySectionModule.editCommunityCategory(categoryId, categoryName, channels);
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteCommunityCategory(categoryId) {
|
2022-01-31 20:32:53 -04:00
|
|
|
chatCommunitySectionModule.deleteCommunityCategory(categoryId);
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
|
|
|
|
2022-02-01 11:31:05 -04:00
|
|
|
function prepareEditCategoryModel(categoryId) {
|
|
|
|
chatCommunitySectionModule.prepareEditCategoryModel(categoryId);
|
2022-02-09 10:43:23 +01:00
|
|
|
}
|
2022-02-01 11:31:05 -04:00
|
|
|
|
2022-01-18 15:54:14 -05:00
|
|
|
function leaveCommunity() {
|
|
|
|
chatCommunitySectionModule.leaveCommunity();
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
|
|
|
|
2022-02-24 16:19:11 -05:00
|
|
|
function removeUserFromCommunity(pubKey) {
|
|
|
|
chatCommunitySectionModule.removeUserFromCommunity(pubKey);
|
|
|
|
}
|
|
|
|
|
2022-04-07 10:49:38 -04:00
|
|
|
function banUserFromCommunity(pubKey) {
|
|
|
|
chatCommunitySectionModule.banUserFromCommunity(pubKey);
|
|
|
|
}
|
|
|
|
|
2022-06-28 17:03:10 +02:00
|
|
|
function unbanUserFromCommunity(pubKey) {
|
|
|
|
chatCommunitySectionModule.unbanUserFromCommunity(pubKey);
|
|
|
|
}
|
|
|
|
|
2022-03-10 14:28:37 -05:00
|
|
|
function createCommunityChannel(channelName, channelDescription, channelEmoji, channelColor,
|
|
|
|
categoryId) {
|
|
|
|
chatCommunitySectionModule.createCommunityChannel(channelName, channelDescription,
|
|
|
|
channelEmoji, channelColor, categoryId);
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
|
|
|
|
2022-03-10 14:28:37 -05:00
|
|
|
function editCommunityChannel(chatId, newName, newDescription, newEmoji, newColor,
|
|
|
|
newCategory, channelPosition) {
|
2022-02-24 16:38:32 -05:00
|
|
|
chatCommunitySectionModule.editCommunityChannel(
|
|
|
|
chatId,
|
|
|
|
newName,
|
|
|
|
newDescription,
|
2022-03-07 09:56:05 -05:00
|
|
|
newEmoji,
|
2022-03-10 14:28:37 -05:00
|
|
|
newColor,
|
2022-02-24 16:38:32 -05:00
|
|
|
newCategory,
|
|
|
|
channelPosition
|
|
|
|
)
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
|
|
|
|
2022-10-19 16:56:00 +04:00
|
|
|
function acceptRequestToJoinCommunity(requestId, communityId) {
|
|
|
|
chatCommunitySectionModule.acceptRequestToJoinCommunity(requestId, communityId)
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
|
|
|
|
2022-10-19 16:56:00 +04:00
|
|
|
function declineRequestToJoinCommunity(requestId, communityId) {
|
|
|
|
chatCommunitySectionModule.declineRequestToJoinCommunity(requestId, communityId)
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
2021-10-28 23:23:30 +03:00
|
|
|
|
|
|
|
function userNameOrAlias(pk) {
|
2021-12-13 15:24:21 +01:00
|
|
|
// Not Refactored Yet
|
|
|
|
// return chatsModelInst.userNameOrAlias(pk);
|
2021-10-28 23:23:30 +03:00
|
|
|
}
|
|
|
|
|
2022-01-21 14:18:56 -05:00
|
|
|
function generateAlias(pk) {
|
|
|
|
return globalUtils.generateAlias(pk);
|
2022-01-11 16:53:18 -05:00
|
|
|
}
|
|
|
|
|
2022-01-17 19:46:46 +01:00
|
|
|
function plainText(text) {
|
|
|
|
return globalUtils.plainText(text)
|
|
|
|
}
|
2022-01-18 18:20:31 +01:00
|
|
|
|
2022-01-25 13:09:27 +01:00
|
|
|
function removeCommunityChat(chatId) {
|
|
|
|
chatCommunitySectionModule.removeCommunityChat(chatId)
|
2022-01-18 18:20:31 +01:00
|
|
|
}
|
2022-01-25 10:51:38 -04:00
|
|
|
|
2022-02-11 16:41:34 -05:00
|
|
|
function reorderCommunityCategories(categoryId, to) {
|
2022-01-25 10:51:38 -04:00
|
|
|
chatCommunitySectionModule.reorderCommunityCategories(categoryId, to)
|
|
|
|
}
|
|
|
|
|
2022-02-11 16:41:34 -05:00
|
|
|
function reorderCommunityChat(categoryId, chatId, to) {
|
2022-01-25 10:51:38 -04:00
|
|
|
chatCommunitySectionModule.reorderCommunityChat(categoryId, chatId, to)
|
|
|
|
}
|
2022-02-11 16:41:34 -05:00
|
|
|
|
2022-09-22 09:13:03 +02:00
|
|
|
function spectateCommunity(id, ensName) {
|
|
|
|
return communitiesModuleInst.spectateCommunity(id, ensName)
|
2022-02-11 16:41:34 -05: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)
|
|
|
|
}
|
|
|
|
|
2022-10-21 13:09:17 +03:00
|
|
|
function cancelPendingRequest(id: string) {
|
|
|
|
communitiesModuleInst.cancelRequestToJoinCommunity(id)
|
|
|
|
}
|
|
|
|
|
2022-02-11 16:41:34 -05:00
|
|
|
function getSectionNameById(id) {
|
|
|
|
return communitiesList.getSectionNameById(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSectionByIdJson(id) {
|
|
|
|
return communitiesList.getSectionByIdJson(id)
|
|
|
|
}
|
|
|
|
|
2022-06-20 13:39:40 +02:00
|
|
|
function requestCommunityInfo(id) {
|
2022-09-22 19:35:18 +03:00
|
|
|
communitiesModuleInst.requestCommunityInfo(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCommunityDetailsAsJson(id) {
|
2022-10-28 17:25:48 +03:00
|
|
|
const jsonObj = communitiesModuleInst.getCommunityDetails(id)
|
2022-09-22 19:35:18 +03:00
|
|
|
try {
|
2022-10-28 17:25:48 +03:00
|
|
|
return JSON.parse(jsonObj)
|
2022-09-22 19:35:18 +03:00
|
|
|
}
|
|
|
|
catch (e) {
|
2022-09-23 17:14:31 +03:00
|
|
|
console.warn("error parsing community by id: ", id, " error: ", e.message)
|
2022-09-22 19:35:18 +03:00
|
|
|
return {}
|
|
|
|
}
|
2022-06-20 13:39:40 +02:00
|
|
|
}
|
|
|
|
|
2022-10-28 17:25:48 +03:00
|
|
|
function getChatDetails(id) {
|
|
|
|
const jsonObj = activityCenterModule.getChatDetailsAsJson(id)
|
|
|
|
try {
|
|
|
|
return JSON.parse(jsonObj)
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.warn("error parsing chat by id: ", id, " error: ", e.message)
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-11 16:41:34 -05:00
|
|
|
function getLinkTitleAndCb(link) {
|
|
|
|
const result = {
|
|
|
|
title: "Status",
|
|
|
|
callback: null
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:05:10 +02:00
|
|
|
// User profile
|
|
|
|
// There is invitation bubble only for /c/ link for now
|
|
|
|
/*let index = link.indexOf("/u/")
|
2022-02-11 16:41:34 -05:00
|
|
|
if (index > -1) {
|
2022-10-20 11:05:10 +02:00
|
|
|
//const pk = link.substring(index + 3)
|
|
|
|
result.title = qsTr("Display user profile")
|
2022-02-11 16:41:34 -05:00
|
|
|
result.callback = function () {
|
2022-10-20 11:05:10 +02:00
|
|
|
mainModuleInst.activateStatusDeepLink(link)
|
2022-02-11 16:41:34 -05:00
|
|
|
}
|
|
|
|
return result
|
2022-10-20 11:05:10 +02:00
|
|
|
}*/
|
2022-02-11 16:41:34 -05:00
|
|
|
|
|
|
|
// Community
|
2022-10-26 16:08:59 +02:00
|
|
|
const communityId = Utils.getCommunityIdFromShareLink(link)
|
|
|
|
if (communityId !== "") {
|
2022-02-11 16:41:34 -05:00
|
|
|
const communityName = getSectionNameById(communityId)
|
|
|
|
|
|
|
|
if (!communityName) {
|
|
|
|
// Unknown community, fetch the info if possible
|
2022-10-26 16:08:59 +02:00
|
|
|
root.requestCommunityInfo(communityId)
|
2022-02-11 16:41:34 -05:00
|
|
|
result.communityId = communityId
|
|
|
|
result.fetching = true
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2022-04-04 13:26:30 +02:00
|
|
|
result.title = qsTr("Join the %1 community").arg(communityName)
|
2022-02-11 16:41:34 -05: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-09-22 09:13:03 +02:00
|
|
|
requestToJoinCommunity(communityId, userProfileInst.ensName)
|
2022-02-11 16:41:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLinkDataForStatusLinks(link) {
|
2022-10-28 10:48:59 +02:00
|
|
|
if (!Utils.isStatusDeepLink(link)) {
|
2022-02-11 16:41:34 -05:00
|
|
|
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 01:04:49 +01:00
|
|
|
|
|
|
|
function getPubkey() {
|
|
|
|
return userProfile.getPubKey()
|
|
|
|
}
|
|
|
|
|
2022-10-17 12:17:25 +02:00
|
|
|
// Needed for TX in chat for stickers and via contact
|
|
|
|
|
|
|
|
property var accounts: walletSectionAccounts.model
|
|
|
|
property var currentAccount: walletSectionCurrent
|
|
|
|
property string currentCurrency: walletSection.currentCurrency
|
|
|
|
property CurrenciesStore currencyStore: CurrenciesStore { }
|
2022-07-01 13:24:32 +02:00
|
|
|
property var allNetworks: networksModule.all
|
2022-10-17 12:17:25 +02:00
|
|
|
property var savedAddressesModel: walletSectionSavedAddresses.model
|
2022-07-01 13:24:32 +02:00
|
|
|
|
2022-10-17 12:17:25 +02:00
|
|
|
property var disabledChainIdsFromList: []
|
|
|
|
property var disabledChainIdsToList: []
|
2022-07-01 13:24:32 +02:00
|
|
|
|
2022-10-17 12:17:25 +02:00
|
|
|
function addRemoveDisabledFromChain(chainID, isDisabled) {
|
|
|
|
if(isDisabled) {
|
|
|
|
disabledChainIdsFromList.push(chainID)
|
2022-07-01 13:24:32 +02:00
|
|
|
}
|
|
|
|
else {
|
2022-10-17 12:17:25 +02:00
|
|
|
for(var i = 0; i < disabledChainIdsFromList.length;i++) {
|
|
|
|
if(disabledChainIdsFromList[i] === chainID) {
|
|
|
|
disabledChainIdsFromList.splice(i, 1)
|
2022-07-01 13:24:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-17 12:17:25 +02:00
|
|
|
function addRemoveDisabledToChain(chainID, isDisabled) {
|
|
|
|
if(isDisabled) {
|
|
|
|
disabledChainIdsToList.push(chainID)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for(var i = 0; i < disabledChainIdsToList.length;i++) {
|
|
|
|
if(disabledChainIdsToList[i] === chainID) {
|
|
|
|
disabledChainIdsToList.splice(i, 1)
|
|
|
|
}
|
2022-07-01 13:24:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-17 12:17:25 +02:00
|
|
|
function getFiatValue(balance, cryptoSymbol, fiatSymbol) {
|
|
|
|
return profileSectionModule.ensUsernamesModule.getFiatValue(balance, cryptoSymbol, fiatSymbol)
|
2022-02-09 01:04:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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 10:53:57 +02: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 01:04:49 +01:00
|
|
|
}
|
|
|
|
|
2022-10-17 12:17:25 +02:00
|
|
|
function authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, priority, selectedRoutes) {
|
|
|
|
walletSectionTransactions.authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, priority, selectedRoutes)
|
2022-02-09 01:04:49 +01: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 10:53:57 +02:00
|
|
|
function suggestedFees(chainId) {
|
|
|
|
return JSON.parse(walletSectionTransactions.suggestedFees(chainId))
|
2022-02-14 19:27:23 -04:00
|
|
|
}
|
|
|
|
|
2022-10-17 12:17:25 +02:00
|
|
|
function suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, priority, sendType) {
|
|
|
|
walletSectionTransactions.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, priority, sendType)
|
|
|
|
}
|
|
|
|
|
|
|
|
function resolveENS(value) {
|
|
|
|
mainModuleInst.resolveENS(value, "")
|
|
|
|
}
|
|
|
|
|
|
|
|
function getWei2Eth(wei) {
|
|
|
|
return globalUtils.wei2Eth(wei,18)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEth2Wei(eth) {
|
|
|
|
return globalUtils.eth2Wei(eth, 18)
|
|
|
|
}
|
|
|
|
|
|
|
|
function switchAccount(newIndex) {
|
|
|
|
if(Constants.isCppApp)
|
|
|
|
walletSectionAccounts.switchAccount(newIndex)
|
|
|
|
else
|
|
|
|
walletSection.switchAccount(newIndex)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEtherscanLink() {
|
|
|
|
return profileSectionModule.ensUsernamesModule.getEtherscanLink()
|
|
|
|
}
|
|
|
|
|
|
|
|
function hex2Eth(value) {
|
|
|
|
return globalUtils.hex2Eth(value)
|
2022-02-14 19:27:23 -04:00
|
|
|
}
|
2021-10-01 18:58:36 +03:00
|
|
|
}
|