From dc77363c3f679cdccf3133b2698bcc4408c119c4 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Sat, 17 Dec 2022 18:08:18 +1300 Subject: [PATCH] Limit group invites to 1 user at a time --- html/src/app.js | 38 +++++++++++++++++++++++--------------- html/src/index.pug | 5 +++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index eff8ce29..4faa9983 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -23812,7 +23812,7 @@ speechSynthesis.getVoices(); groupId: '', groupName: '', userId: '', - userIds: [], + userIds: '', userObject: {}, groups: [] }; @@ -23820,7 +23820,7 @@ speechSynthesis.getVoices(); $app.methods.showInviteGroupDialog = function (groupId, userId) { this.$nextTick(() => adjustDialogZ(this.$refs.inviteGroupDialog.$el)); var D = this.inviteGroupDialog; - D.userIds = []; + D.userIds = ''; D.groups = []; D.groupId = groupId; D.groupName = groupId; @@ -23849,7 +23849,8 @@ speechSynthesis.getVoices(); API.getCachedUser({userId}).then((args) => { D.userObject = args.ref; }); - D.userIds = [userId]; + // D.userIds = [userId]; + D.userIds = userId; } }; @@ -23868,18 +23869,25 @@ speechSynthesis.getVoices(); return; } D.loading = true; - var inviteLoop = () => { - if (D.userIds.length > 0) { - var receiverUserId = D.userIds.shift(); - API.sendGroupInvite({ - groupId: D.groupId, - userId: receiverUserId - }).finally(inviteLoop); - } else { - D.loading = false; - } - }; - inviteLoop(); + // no fun allowed + // var inviteLoop = () => { + // if (D.userIds.length > 0) { + // var receiverUserId = D.userIds.shift(); + // API.sendGroupInvite({ + // groupId: D.groupId, + // userId: receiverUserId + // }).finally(inviteLoop); + // } else { + // D.loading = false; + // } + // }; + var receiverUserId = D.userIds; + API.sendGroupInvite({ + groupId: D.groupId, + userId: receiverUserId + }).finally(() => { + D.loading = false; + }); } }); }; diff --git a/html/src/index.pug b/html/src/index.pug index 8d1c9244..9d73a2d0 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -3661,7 +3661,8 @@ html //- dialog: invite group el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="inviteGroupDialog" :visible.sync="inviteGroupDialog.visible" title="Invite To Group" width="450px") div(v-if="inviteGroupDialog.visible" v-loading="inviteGroupDialog.loading") - span The limits for this are unknown be careful when using it, inviting too many users to a group is known to cause a ban. + span Don't spam invite users, inviting too many users to a group is known to cause a ban. + br el-select(v-model="inviteGroupDialog.groupId" clearable placeholder="Choose Group" filterable :disabled="inviteGroupDialog.loading" @change="isAllowedToInviteToGroup" style="margin-top:15px") el-option-group(v-if="inviteGroupDialog.groups.length" label="Groups" style="width:410px") el-option.x-friend-item(v-for="group in inviteGroupDialog.groups" :key="group.id" :label="group.name" :value="group.id" style="height:auto") @@ -3669,7 +3670,7 @@ html img(v-lazy="group.iconUrl") .detail span.name(v-text="group.name") - el-select(v-model="inviteGroupDialog.userIds" multiple clearable placeholder="Choose Friends" filterable :disabled="inviteGroupDialog.loading" style="width:100%;margin-top:15px") + el-select(v-model="inviteGroupDialog.userIds" clearable placeholder="Choose Friends" filterable :disabled="inviteGroupDialog.loading" style="width:100%;margin-top:15px") el-option-group(v-if="inviteGroupDialog.userId" label="Selected User") el-option.x-friend-item(:key="inviteGroupDialog.userObject.id" :label="inviteGroupDialog.userObject.displayName" :value="inviteGroupDialog.userObject.id" style="height:auto") template(v-if="inviteGroupDialog.userObject.id")