Limit group invites to 1 user at a time

This commit is contained in:
Natsumi
2022-12-17 18:08:18 +13:00
parent 9ec7dbbe55
commit dc77363c3f
2 changed files with 26 additions and 17 deletions

View File

@@ -23812,7 +23812,7 @@ speechSynthesis.getVoices();
groupId: '', groupId: '',
groupName: '', groupName: '',
userId: '', userId: '',
userIds: [], userIds: '',
userObject: {}, userObject: {},
groups: [] groups: []
}; };
@@ -23820,7 +23820,7 @@ speechSynthesis.getVoices();
$app.methods.showInviteGroupDialog = function (groupId, userId) { $app.methods.showInviteGroupDialog = function (groupId, userId) {
this.$nextTick(() => adjustDialogZ(this.$refs.inviteGroupDialog.$el)); this.$nextTick(() => adjustDialogZ(this.$refs.inviteGroupDialog.$el));
var D = this.inviteGroupDialog; var D = this.inviteGroupDialog;
D.userIds = []; D.userIds = '';
D.groups = []; D.groups = [];
D.groupId = groupId; D.groupId = groupId;
D.groupName = groupId; D.groupName = groupId;
@@ -23849,7 +23849,8 @@ speechSynthesis.getVoices();
API.getCachedUser({userId}).then((args) => { API.getCachedUser({userId}).then((args) => {
D.userObject = args.ref; D.userObject = args.ref;
}); });
D.userIds = [userId]; // D.userIds = [userId];
D.userIds = userId;
} }
}; };
@@ -23868,18 +23869,25 @@ speechSynthesis.getVoices();
return; return;
} }
D.loading = true; D.loading = true;
var inviteLoop = () => { // no fun allowed
if (D.userIds.length > 0) { // var inviteLoop = () => {
var receiverUserId = D.userIds.shift(); // if (D.userIds.length > 0) {
API.sendGroupInvite({ // var receiverUserId = D.userIds.shift();
groupId: D.groupId, // API.sendGroupInvite({
userId: receiverUserId // groupId: D.groupId,
}).finally(inviteLoop); // userId: receiverUserId
} else { // }).finally(inviteLoop);
D.loading = false; // } else {
} // D.loading = false;
}; // }
inviteLoop(); // };
var receiverUserId = D.userIds;
API.sendGroupInvite({
groupId: D.groupId,
userId: receiverUserId
}).finally(() => {
D.loading = false;
});
} }
}); });
}; };

View File

@@ -3661,7 +3661,8 @@ html
//- dialog: invite group //- 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") 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") 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-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-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") 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") img(v-lazy="group.iconUrl")
.detail .detail
span.name(v-text="group.name") 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-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") 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") template(v-if="inviteGroupDialog.userObject.id")