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: '',
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;
});
}
});
};

View File

@@ -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")