From 320104ac2a098a3d277a2562c2fad35d28b27768 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Fri, 15 Nov 2024 14:02:32 +1300 Subject: [PATCH] New Instance and Self Invite --- html/src/app.js | 97 ++++++++++++------------- html/src/localization/en/en.json | 1 + html/src/mixins/dialogs/worldDialog.pug | 1 + html/src/mixins/tabs/notifications.pug | 4 +- 4 files changed, 51 insertions(+), 52 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index fe59b7c4c..c1cd5a8c6 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -11284,6 +11284,19 @@ speechSynthesis.getVoices(); case 'New Instance': this.showNewInstanceDialog(D.$location.tag); break; + case 'New Instance and Self Invite': + this.newInstanceDialog.worldId = D.id; + this.createNewInstance().then((args) => { + if (!args?.json?.location) { + this.$message({ + message: 'Failed to create instance', + type: 'error' + }); + return; + } + this.selfInvite(args.json.location); + }); + break; case 'Add Favorite': this.showFavoriteDialog('world', D.id); break; @@ -12266,16 +12279,28 @@ speechSynthesis.getVoices(); loading: false, selectedTab: '0', instanceCreated: false, - queueEnabled: false, + queueEnabled: await configRepository.getBool( + 'instanceDialogQueueEnabled', + true + ), worldId: '', instanceId: '', - instanceName: '', - userId: '', - accessType: '', - region: '', + instanceName: await configRepository.getString( + 'instanceDialogInstanceName', + '' + ), + userId: await configRepository.getString('instanceDialogUserId', ''), + accessType: await configRepository.getString( + 'instanceDialogAccessType', + 'public' + ), + region: await configRepository.getString('instanceRegion', ''), groupRegion: '', - groupId: '', - groupAccessType: '', + groupId: await configRepository.getString('instanceDialogGroupId', ''), + groupAccessType: await configRepository.getString( + 'instanceDialogGroupAccessType', + 'plus' + ), strict: false, location: '', shortName: '', @@ -12397,7 +12422,7 @@ speechSynthesis.getVoices(); this.saveNewInstanceDialog(); }; - $app.methods.createNewInstance = function () { + $app.methods.createNewInstance = async function () { var D = this.newInstanceDialog; if (D.loading) { return; @@ -12449,19 +12474,20 @@ speechSynthesis.getVoices(); params.canRequestInvite = true; } } - API.createInstance(params) - .then((args) => { - D.location = args.json.location; - D.instanceId = args.json.instanceId; - D.secureOrShortName = - args.json.shortName || args.json.secureName; - D.instanceCreated = true; - this.updateNewInstanceDialog(); - return args; - }) - .finally(() => { - D.loading = false; - }); + try { + var args = await API.createInstance(params); + D.location = args.json.location; + D.instanceId = args.json.instanceId; + D.secureOrShortName = args.json.shortName || args.json.secureName; + D.instanceCreated = true; + this.updateNewInstanceDialog(); + D.loading = false; + return args; + } catch (err) { + D.loading = false; + console.error(err); + return null; + } }; $app.methods.selfInvite = function (location, shortName) { @@ -12527,10 +12553,6 @@ speechSynthesis.getVoices(); 'instanceDialogGroupAccessType', this.newInstanceDialog.groupAccessType ); - await configRepository.setBool( - 'instanceDialogStrict', - this.newInstanceDialog.strict - ); await configRepository.setBool( 'instanceDialogQueueEnabled', this.newInstanceDialog.queueEnabled @@ -12552,31 +12574,6 @@ speechSynthesis.getVoices(); return; } D.worldId = L.worldId; - D.accessType = await configRepository.getString( - 'instanceDialogAccessType', - 'public' - ); - D.region = await configRepository.getString( - 'instanceRegion', - 'US West' - ); - D.instanceName = await configRepository.getString( - 'instanceDialogInstanceName', - '' - ); - D.userId = await configRepository.getString('instanceDialogUserId', ''); - D.groupId = await configRepository.getString( - 'instanceDialogGroupId', - '' - ); - D.groupAccessType = await configRepository.getString( - 'instanceDialogGroupAccessType', - 'plus' - ); - D.queueEnabled = await configRepository.getBool( - 'instanceDialogQueueEnabled', - true - ); D.instanceCreated = false; D.lastSelectedGroupId = ''; D.selectedGroupRoles = []; diff --git a/html/src/localization/en/en.json b/html/src/localization/en/en.json index aab565bbe..24212b073 100644 --- a/html/src/localization/en/en.json +++ b/html/src/localization/en/en.json @@ -712,6 +712,7 @@ "favorites_tooltip": "Favorites", "refresh": "Refresh", "new_instance": "New Instance", + "new_instance_and_self_invite": "New Instance and Self Invite", "make_home": "Make Home", "reset_home": "Reset Home", "show_previous_instances": "Show Previous Instances", diff --git a/html/src/mixins/dialogs/worldDialog.pug b/html/src/mixins/dialogs/worldDialog.pug index 38e123ee0..aec037627 100644 --- a/html/src/mixins/dialogs/worldDialog.pug +++ b/html/src/mixins/dialogs/worldDialog.pug @@ -53,6 +53,7 @@ mixin worldDialog() el-dropdown-menu(#default="dropdown") el-dropdown-item(icon="el-icon-refresh" command="Refresh") {{ $t('dialog.world.actions.refresh') }} el-dropdown-item(icon="el-icon-s-flag" command="New Instance" divided) {{ $t('dialog.world.actions.new_instance') }} + el-dropdown-item(icon="el-icon-message" command="New Instance and Self Invite") {{ $t('dialog.world.actions.new_instance_and_self_invite') }} el-dropdown-item(v-if="API.currentUser.$homeLocation && API.currentUser.$homeLocation.worldId === worldDialog.id" icon="el-icon-magic-stick" command="Reset Home" divided) {{ $t('dialog.world.actions.reset_home') }} el-dropdown-item(v-else icon="el-icon-s-home" command="Make Home" divided) {{ $t('dialog.world.actions.make_home') }} el-dropdown-item(icon="el-icon-tickets" command="Previous Instances") {{ $t('dialog.world.actions.show_previous_instances') }} diff --git a/html/src/mixins/tabs/notifications.pug b/html/src/mixins/tabs/notifications.pug index 263b0b771..2acc0dbfd 100644 --- a/html/src/mixins/tabs/notifications.pug +++ b/html/src/mixins/tabs/notifications.pug @@ -50,8 +50,8 @@ mixin notificationsTab() img.x-link(v-lazy="scope.row.imageUrl" style="width:500px" @click="showFullscreenImageDialog(scope.row.imageUrl)") el-table-column(:label="$t('table.notification.message')" prop="message") template(v-once #default="scope") - span.x-link(v-if="scope.row.type === 'invite'" @click="showWorldDialog(scope.row.details.worldId)") - location(v-if="scope.row.details" :location="scope.row.details.worldId" :hint="scope.row.details.worldName" :grouphint="scope.row.details.groupName" :link="false") + span.x-link(v-if="scope.row.type === 'invite'") + location(v-if="scope.row.details" :location="scope.row.details.worldId" :hint="scope.row.details.worldName" :grouphint="scope.row.details.groupName" :link="true") br span(v-if="scope.row.message && scope.row.message !== `This is a generated invite to ${scope.row.details?.worldName}`" v-text="scope.row.message") span(v-else-if='scope.row.details && scope.row.details.inviteMessage' v-text="scope.row.details.inviteMessage")