2022-05-23 13:11:30 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQml.Models 2.2
|
|
|
|
|
2022-11-28 14:57:56 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2022-05-23 13:11:30 +00:00
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var communitiesModuleInst: communitiesModule
|
2022-11-28 14:57:56 +00:00
|
|
|
property var mainModuleInst: mainModule
|
2022-09-28 15:25:49 +00:00
|
|
|
|
2022-10-18 08:48:17 +00:00
|
|
|
readonly property var curatedCommunitiesModel: root.communitiesModuleInst.curatedCommunities
|
2023-01-31 13:03:25 +00:00
|
|
|
readonly property bool curatedCommunitiesLoading: root.communitiesModuleInst.curatedCommunitiesLoading
|
2022-09-28 15:25:49 +00:00
|
|
|
|
2022-08-18 15:59:12 +00:00
|
|
|
property var discordFileList: root.communitiesModuleInst.discordFileList
|
|
|
|
property var discordCategoriesModel: root.communitiesModuleInst.discordCategories
|
|
|
|
property var discordChannelsModel: root.communitiesModuleInst.discordChannels
|
|
|
|
property int discordOldestMessageTimestamp: root.communitiesModuleInst.discordOldestMessageTimestamp
|
|
|
|
property bool discordDataExtractionInProgress: root.communitiesModuleInst.discordDataExtractionInProgress
|
|
|
|
property int discordImportErrorsCount: root.communitiesModuleInst.discordImportErrorsCount
|
|
|
|
property int discordImportWarningsCount: root.communitiesModuleInst.discordImportWarningsCount
|
2022-09-15 07:31:38 +00:00
|
|
|
property int discordImportProgress: root.communitiesModuleInst.discordImportProgress
|
|
|
|
property bool discordImportInProgress: root.communitiesModuleInst.discordImportInProgress
|
|
|
|
property bool discordImportCancelled: root.communitiesModuleInst.discordImportCancelled
|
|
|
|
property bool discordImportProgressStopped: root.communitiesModuleInst.discordImportProgressStopped
|
2023-01-26 14:32:23 +00:00
|
|
|
property int discordImportProgressTotalChunksCount: root.communitiesModuleInst.discordImportProgressTotalChunksCount
|
|
|
|
property int discordImportProgressCurrentChunk: root.communitiesModuleInst.discordImportProgressCurrentChunk
|
2022-09-15 07:31:38 +00:00
|
|
|
property string discordImportCommunityId: root.communitiesModuleInst.discordImportCommunityId
|
|
|
|
property string discordImportCommunityName: root.communitiesModuleInst.discordImportCommunityName
|
2023-09-01 07:58:48 +00:00
|
|
|
property string discordImportChannelId: root.communitiesModuleInst.discordImportChannelId
|
|
|
|
property string discordImportChannelName: root.communitiesModuleInst.discordImportChannelName
|
2022-11-04 14:01:04 +00:00
|
|
|
property url discordImportCommunityImage: root.communitiesModuleInst.discordImportCommunityImage
|
|
|
|
property bool discordImportHasCommunityImage: root.communitiesModuleInst.discordImportHasCommunityImage
|
2022-09-15 07:31:38 +00:00
|
|
|
property var discordImportTasks: root.communitiesModuleInst.discordImportTasks
|
2022-12-01 15:10:51 +00:00
|
|
|
property bool downloadingCommunityHistoryArchives: root.communitiesModuleInst.downloadingCommunityHistoryArchives
|
2022-06-21 08:57:09 +00:00
|
|
|
property var advancedModule: profileSectionModule.advancedModule
|
2022-05-23 13:11:30 +00:00
|
|
|
|
2024-04-29 18:35:44 +00:00
|
|
|
readonly property bool createCommunityEnabled: localAppSettings.createCommunityEnabled ?? false
|
|
|
|
readonly property bool testEnvironment: localAppSettings.testEnvironment ?? false
|
|
|
|
|
2022-06-16 09:41:21 +00:00
|
|
|
property string communityTags: communitiesModuleInst.tags
|
|
|
|
|
2022-11-28 14:57:56 +00:00
|
|
|
signal importingCommunityStateChanged(string communityId, int state, string errorMsg)
|
2023-07-31 15:56:00 +00:00
|
|
|
|
2023-10-27 10:25:27 +00:00
|
|
|
signal communityInfoRequestCompleted(string communityId, string errorMsg)
|
|
|
|
|
2022-06-21 08:57:09 +00:00
|
|
|
function createCommunity(args = {
|
|
|
|
name: "",
|
|
|
|
description: "",
|
|
|
|
introMessage: "",
|
|
|
|
outroMessage: "",
|
|
|
|
color: "",
|
2022-06-16 09:41:21 +00:00
|
|
|
tags: "",
|
2022-06-21 08:57:09 +00:00
|
|
|
image: {
|
|
|
|
src: "",
|
|
|
|
AX: 0,
|
|
|
|
AY: 0,
|
|
|
|
BX: 0,
|
|
|
|
BY: 0,
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
historyArchiveSupportEnabled: false,
|
|
|
|
checkedMembership: false,
|
2022-10-07 16:33:23 +00:00
|
|
|
pinMessagesAllowedForMembers: false,
|
|
|
|
encrypted: false,
|
2022-08-17 12:44:53 +00:00
|
|
|
},
|
|
|
|
bannerJsonStr: ""
|
2022-06-21 08:57:09 +00:00
|
|
|
}) {
|
|
|
|
return communitiesModuleInst.createCommunity(
|
2022-06-16 09:41:21 +00:00
|
|
|
args.name, args.description, args.introMessage, args.outroMessage, args.options.checkedMembership,
|
|
|
|
args.color, args.tags,
|
2022-06-21 08:57:09 +00:00
|
|
|
args.image.src, args.image.AX, args.image.AY, args.image.BX, args.image.BY,
|
2022-10-07 16:33:23 +00:00
|
|
|
args.options.historyArchiveSupportEnabled, args.options.pinMessagesAllowedForMembers,
|
|
|
|
args.bannerJsonStr, args.options.encrypted);
|
2022-06-21 08:57:09 +00:00
|
|
|
}
|
|
|
|
|
2023-07-31 15:56:00 +00:00
|
|
|
function getCommunityPublicKeyFromPrivateKey(privateKey) {
|
|
|
|
return root.communitiesModuleInst.getCommunityPublicKeyFromPrivateKey(privateKey);
|
|
|
|
}
|
|
|
|
|
2024-10-21 13:40:14 +00:00
|
|
|
function requestCommunityInfo(communityPubKey, shardCluster, shardIndex, importing = false) {
|
2023-07-21 17:21:11 +00:00
|
|
|
if (importing)
|
2024-10-21 13:40:14 +00:00
|
|
|
root.mainModuleInst.setCommunityIdToSpectate(communityPubKey)
|
|
|
|
root.communitiesModuleInst.requestCommunityInfo(communityPubKey, shardCluster, shardIndex, importing)
|
2022-11-28 14:57:56 +00:00
|
|
|
}
|
|
|
|
|
2023-07-21 17:21:11 +00:00
|
|
|
property var communitiesList: communitiesModuleInst.model
|
2023-08-22 18:04:58 +00:00
|
|
|
readonly property bool requirementsCheckPending: communitiesModuleInst.requirementsCheckPending
|
2023-07-21 17:21:11 +00:00
|
|
|
|
|
|
|
function spectateCommunity(publicKey) {
|
|
|
|
root.communitiesModuleInst.spectateCommunity(publicKey, "");
|
|
|
|
}
|
|
|
|
|
2023-08-01 18:32:10 +00:00
|
|
|
function prepareTokenModelForCommunity(publicKey) {
|
|
|
|
root.communitiesModuleInst.prepareTokenModelForCommunity(publicKey);
|
|
|
|
}
|
|
|
|
|
2024-10-21 13:40:14 +00:00
|
|
|
function getCommunityDetails(communityPubKey) {
|
2023-07-21 17:21:11 +00:00
|
|
|
try {
|
2024-10-21 13:40:14 +00:00
|
|
|
const communityJson = root.communitiesList.getSectionByIdJson(communityPubKey)
|
2023-10-27 10:25:27 +00:00
|
|
|
if (!!communityJson)
|
|
|
|
return JSON.parse(communityJson)
|
2023-07-21 17:21:11 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error("Error parsing community", e)
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCommunityDetailsAsJson(communityId) {
|
|
|
|
const jsonObj = root.communitiesModuleInst.getCommunityDetails(communityId)
|
|
|
|
try {
|
|
|
|
return JSON.parse(jsonObj)
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.warn("error parsing community by id: ", communityId, " error: ", e.message)
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-21 08:57:09 +00:00
|
|
|
function setActiveCommunity(communityId) {
|
2023-02-28 15:00:10 +00:00
|
|
|
root.mainModuleInst.setActiveSectionById(communityId);
|
2022-06-21 08:57:09 +00:00
|
|
|
}
|
2022-08-18 15:59:12 +00:00
|
|
|
|
2022-10-18 13:55:02 +00:00
|
|
|
function navigateToCommunity(communityId) {
|
|
|
|
root.communitiesModuleInst.navigateToCommunity(communityId)
|
|
|
|
}
|
|
|
|
|
2022-11-08 14:07:14 +00:00
|
|
|
function removeFileListItem(filePath) {
|
|
|
|
root.communitiesModuleInst.removeFileListItem(filePath)
|
|
|
|
}
|
2023-09-01 07:58:48 +00:00
|
|
|
|
2022-08-18 15:59:12 +00:00
|
|
|
function setFileListItems(filePaths) {
|
|
|
|
root.communitiesModuleInst.setFileListItems(filePaths)
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearFileList() {
|
|
|
|
root.communitiesModuleInst.clearFileList()
|
|
|
|
}
|
|
|
|
|
|
|
|
function requestExtractChannelsAndCategories() {
|
|
|
|
root.communitiesModuleInst.requestExtractDiscordChannelsAndCategories()
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearDiscordCategoriesAndChannels() {
|
|
|
|
root.communitiesModuleInst.clearDiscordCategoriesAndChannels()
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleDiscordCategory(id, selected) {
|
|
|
|
root.communitiesModuleInst.toggleDiscordCategory(id, selected)
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleDiscordChannel(id, selected) {
|
|
|
|
root.communitiesModuleInst.toggleDiscordChannel(id, selected)
|
2023-09-01 07:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleOneDiscordChannel(id) {
|
|
|
|
root.communitiesModuleInst.toggleOneDiscordChannel(id)
|
|
|
|
}
|
2022-09-15 07:31:38 +00:00
|
|
|
|
|
|
|
function requestCancelDiscordCommunityImport(id) {
|
|
|
|
root.communitiesModuleInst.requestCancelDiscordCommunityImport(id)
|
|
|
|
}
|
|
|
|
|
2023-09-01 07:58:48 +00:00
|
|
|
function requestCancelDiscordChannelImport(id) {
|
2023-10-16 18:26:47 +00:00
|
|
|
root.communitiesModuleInst.requestCancelDiscordChannelImport(id)
|
2023-09-01 07:58:48 +00:00
|
|
|
}
|
|
|
|
|
2024-02-08 16:44:49 +00:00
|
|
|
function resetImport() {
|
|
|
|
root.communitiesModuleInst.resetImport()
|
|
|
|
}
|
|
|
|
|
2023-11-10 13:24:35 +00:00
|
|
|
function removeImportedDiscordChannel() {
|
|
|
|
root.communitiesModuleInst.removeImportedDiscordChannel()
|
|
|
|
}
|
|
|
|
|
2022-09-15 07:31:38 +00:00
|
|
|
function resetDiscordImport() {
|
|
|
|
root.communitiesModuleInst.resetDiscordImport(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
function requestImportDiscordCommunity(args = {
|
|
|
|
name: "",
|
|
|
|
description: "",
|
|
|
|
introMessage: "",
|
|
|
|
outroMessage: "",
|
|
|
|
color: "",
|
|
|
|
tags: "",
|
|
|
|
image: {
|
|
|
|
src: "",
|
|
|
|
AX: 0,
|
|
|
|
AY: 0,
|
|
|
|
BX: 0,
|
|
|
|
BY: 0,
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
historyArchiveSupportEnabled: false,
|
|
|
|
checkedMembership: false,
|
2022-10-07 16:33:23 +00:00
|
|
|
pinMessagesAllowedForMembers: false,
|
2022-09-15 07:31:38 +00:00
|
|
|
}
|
|
|
|
}, from = 0) {
|
|
|
|
return communitiesModuleInst.requestImportDiscordCommunity(
|
|
|
|
args.name, args.description, args.introMessage, args.outroMessage, args.options.checkedMembership,
|
|
|
|
args.color, args.tags,
|
|
|
|
args.image.src, args.image.AX, args.image.AY, args.image.BX, args.image.BY,
|
2023-05-04 13:28:34 +00:00
|
|
|
args.options.historyArchiveSupportEnabled, args.options.pinMessagesAllowedForMembers, from);
|
2022-08-18 15:59:12 +00:00
|
|
|
}
|
2022-11-28 14:57:56 +00:00
|
|
|
|
2023-09-01 07:58:48 +00:00
|
|
|
function requestImportDiscordChannel(args = {
|
2023-10-16 18:26:47 +00:00
|
|
|
communityId: "",
|
2023-09-01 07:58:48 +00:00
|
|
|
discordChannelId: "",
|
|
|
|
name: "",
|
|
|
|
description: "",
|
|
|
|
color: "",
|
|
|
|
emoji: "",
|
|
|
|
options: {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
}, from = 0) {
|
2023-10-16 18:26:47 +00:00
|
|
|
communitiesModuleInst.requestImportDiscordChannel(args.name, args.discordChannelId, args.communityId,
|
|
|
|
args.description, args.color, args.emoji, from)
|
2023-09-01 07:58:48 +00:00
|
|
|
}
|
2022-11-28 14:57:56 +00:00
|
|
|
|
2024-10-16 07:56:23 +00:00
|
|
|
function isDisplayNameDupeOfCommunityMember(displayName) {
|
|
|
|
if (displayName === "")
|
|
|
|
return false
|
|
|
|
|
|
|
|
return communitiesModuleInst.isDisplayNameDupeOfCommunityMember(displayName)
|
|
|
|
}
|
|
|
|
|
2022-11-28 14:57:56 +00:00
|
|
|
readonly property Connections connections: Connections {
|
2023-06-14 08:42:52 +00:00
|
|
|
target: communitiesModuleInst
|
|
|
|
function onImportingCommunityStateChanged(communityId, state, errorMsg) {
|
|
|
|
root.importingCommunityStateChanged(communityId, state, errorMsg)
|
|
|
|
}
|
2023-07-27 12:33:33 +00:00
|
|
|
|
2023-10-27 10:25:27 +00:00
|
|
|
function onCommunityInfoRequestCompleted(communityId, erorrMsg) {
|
|
|
|
root.communityInfoRequestCompleted(communityId, erorrMsg)
|
|
|
|
}
|
2022-11-28 14:57:56 +00:00
|
|
|
}
|
2022-05-23 13:11:30 +00:00
|
|
|
}
|