diff --git a/html/src/app.js b/html/src/app.js index 95cb0b39..4b9c3bb2 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -662,6 +662,63 @@ CefSharp.BindObjectAsync( } }); + Vue.component('invite-yourself', { + template: '', + props: { + location: String + }, + methods: { + parse() { + var L = API.parseLocation(this.location); + this.$el.style.display = L.isOffline || L.isPrivate + ? 'none' + : ''; + }, + confirm() { + var L = API.parseLocation(this.location); + if (L.isOffline || + L.isPrivate || + L.worldId === '') { + return; + } + API.getCachedWorld({ + worldId: L.worldId + }).then((args) => { + var params = { + receiverUserId: API.currentUser.id, + type: 'invite', + message: 'This is a generated invite', + seen: false, + details: { + worldId: L.tag, + worldName: args.ref.name + } + }; + if (API.currentUser.status === 'busy') { + this.$message({ + message: 'You can\'t invite yourself in \'Do Not Disturb\' mode', + type: 'error' + }); + return; + } + API.sendNotification(params).finally(() => { + this.$message({ + message: 'Invite sent to yourself', + type: 'success' + }); + }); + }); + } + }, + watch: { + location() { + this.parse(); + } + }, + mounted() { + this.parse(); + } + }); Vue.component('location', { template: '{{ text }}', diff --git a/html/src/index.pug b/html/src/index.pug index bd2b6649..95a6f747 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -694,6 +694,7 @@ html location(:location="userDialog.ref.location") template(#default v-if="userDialog.instance.occupants") ({{ userDialog.instance.occupants }}) launch(:location="userDialog.ref.location" style="margin-left:5px") + invite-yourself(:location="userDialog.ref.location" style="margin-left:5px") .x-friend-list(style="flex:1;margin-top:10px") .x-friend-item(v-if="userDialog.$location.userId" @click="showUserDialog(userDialog.$location.userId)") template(v-if="userDialog.$location.user") @@ -810,6 +811,7 @@ html div(style="margin:5px 0") span.x-link(@click="showLaunchDialog(room.$location.tag)"). \#{{ room.$location.instanceName }} {{ room.$location.accessType }} #[template(v-if="room.occupants") ({{ room.occupants }})] + invite-yourself(:location="room.$location.tag" style="margin-left:5px") .x-friend-list(style="margin:10px 0" v-if="room.$location.userId || room.users.length") .x-friend-item(v-if="room.$location.userId" @click="showUserDialog(room.$location.userId)") template(v-if="room.$location.user")