GroupAccessType

This commit is contained in:
Natsumi
2023-05-23 19:54:58 +12:00
parent b78dfb863c
commit 7d7a71b74e
3 changed files with 114 additions and 47 deletions
+98 -45
View File
@@ -731,6 +731,7 @@ speechSynthesis.getVoices();
privateId: null, privateId: null,
friendsId: null, friendsId: null,
groupId: null, groupId: null,
groupAccessType: null,
canRequestInvite: false, canRequestInvite: false,
strict: false strict: false
}; };
@@ -772,6 +773,8 @@ speechSynthesis.getVoices();
ctx.region = value; ctx.region = value;
} else if (key === 'group') { } else if (key === 'group') {
ctx.groupId = value; ctx.groupId = value;
} else if (key === 'groupAccessType') {
ctx.groupAccessType = value;
} else if (key === 'strict') { } else if (key === 'strict') {
ctx.strict = true; ctx.strict = true;
} }
@@ -908,6 +911,11 @@ speechSynthesis.getVoices();
} }
this.text = instanceId; this.text = instanceId;
var L = API.parseLocation(instanceId); var L = API.parseLocation(instanceId);
var groupAccessType = '';
if (L.groupAccessType) {
if (L.groupAccessType === 'public')
groupAccessType = 'Public';
}
if (L.isOffline) { if (L.isOffline) {
this.text = 'Offline'; this.text = 'Offline';
} else if (L.isPrivate) { } else if (L.isPrivate) {
@@ -916,7 +924,7 @@ speechSynthesis.getVoices();
this.text = 'Traveling'; this.text = 'Traveling';
} else if (typeof this.hint === 'string' && this.hint !== '') { } else if (typeof this.hint === 'string' && this.hint !== '') {
if (L.instanceId) { if (L.instanceId) {
this.text = `${this.hint} #${L.instanceName} ${L.accessType}`; this.text = `${this.hint} #${L.instanceName} ${L.accessType}${groupAccessType}`;
} else { } else {
this.text = this.hint; this.text = this.hint;
} }
@@ -926,14 +934,14 @@ speechSynthesis.getVoices();
$app.getWorldName(L.worldId).then((worldName) => { $app.getWorldName(L.worldId).then((worldName) => {
if (L.tag === instanceId) { if (L.tag === instanceId) {
if (L.instanceId) { if (L.instanceId) {
this.text = `${worldName} #${L.instanceName} ${L.accessType}`; this.text = `${worldName} #${L.instanceName} ${L.accessType}${groupAccessType}`;
} else { } else {
this.text = worldName; this.text = worldName;
} }
} }
}); });
} else if (L.instanceId) { } else if (L.instanceId) {
this.text = `${ref.name} #${L.instanceName} ${L.accessType}`; this.text = `${ref.name} #${L.instanceName} ${L.accessType}${groupAccessType}`;
} else { } else {
this.text = ref.name; this.text = ref.name;
} }
@@ -994,7 +1002,7 @@ speechSynthesis.getVoices();
template: template:
'<span><span @click="showLaunchDialog" class="x-link">' + '<span><span @click="showLaunchDialog" class="x-link">' +
'<i v-if="isUnlocked" class="el-icon el-icon-unlock" style="display:inline-block;margin-right:5px"></i>' + '<i v-if="isUnlocked" class="el-icon el-icon-unlock" style="display:inline-block;margin-right:5px"></i>' +
'<span>#{{ instanceName }} {{ accessType }}</span></span>' + '<span>#{{ instanceName }} {{ accessType }}{{ groupAccessType }}</span></span>' +
'<span v-if="groupName" @click="showGroupDialog" class="x-link">({{ groupName }})</span>' + '<span v-if="groupName" @click="showGroupDialog" class="x-link">({{ groupName }})</span>' +
'<span class="flags" :class="region" style="display:inline-block;margin-left:5px"></span>' + '<span class="flags" :class="region" style="display:inline-block;margin-left:5px"></span>' +
'<i v-if="strict" class="el-icon el-icon-lock" style="display:inline-block;margin-left:5px"></i></span>', '<i v-if="strict" class="el-icon el-icon-lock" style="display:inline-block;margin-left:5px"></i></span>',
@@ -1012,6 +1020,7 @@ speechSynthesis.getVoices();
location: this.location, location: this.location,
instanceName: this.instanceName, instanceName: this.instanceName,
accessType: this.accessType, accessType: this.accessType,
groupAccessType: this.groupAccessType,
region: this.region, region: this.region,
shortName: this.shortName, shortName: this.shortName,
isUnlocked: this.isUnlocked, isUnlocked: this.isUnlocked,
@@ -1038,6 +1047,13 @@ speechSynthesis.getVoices();
this.isUnlocked = true; this.isUnlocked = true;
} }
this.groupAccessType = '';
if (this.locationobject.groupAccessType) {
if (this.locationobject.groupAccessType === 'public') {
this.groupAccessType = 'Public';
}
}
this.region = this.locationobject.region; this.region = this.locationobject.region;
if (!this.region) { if (!this.region) {
this.region = 'us'; this.region = 'us';
@@ -3613,12 +3629,14 @@ speechSynthesis.getVoices();
this.cachedFavoritesByObjectId.clear(); this.cachedFavoritesByObjectId.clear();
this.cachedFavoriteGroups.clear(); this.cachedFavoriteGroups.clear();
this.cachedFavoriteGroupsByTypeName.clear(); this.cachedFavoriteGroupsByTypeName.clear();
this.currentUserGroups.clear();
this.favoriteFriendGroups = []; this.favoriteFriendGroups = [];
this.favoriteWorldGroups = []; this.favoriteWorldGroups = [];
this.favoriteAvatarGroups = []; this.favoriteAvatarGroups = [];
this.isFavoriteLoading = false; this.isFavoriteLoading = false;
this.isFavoriteGroupLoading = false; this.isFavoriteGroupLoading = false;
this.refreshFavorites(); this.refreshFavorites();
$app.getCurrentUserGroups();
}); });
API.$on('FAVORITE', function (args) { API.$on('FAVORITE', function (args) {
@@ -4570,6 +4588,19 @@ speechSynthesis.getVoices();
break; break;
case 'group-joined': case 'group-joined':
var groupId = content.groupId;
if (
$app.groupDialog.visible &&
$app.groupDialog.id === groupId
) {
$app.showGroupDialog(groupId);
}
if (!this.currentUserGroups.has(groupId)) {
this.currentUserGroups.set(groupId);
this.getGroup({ groupId });
}
break;
case 'group-left': case 'group-left':
var groupId = content.groupId; var groupId = content.groupId;
if ( if (
@@ -4578,7 +4609,9 @@ speechSynthesis.getVoices();
) { ) {
$app.showGroupDialog(groupId); $app.showGroupDialog(groupId);
} }
this.currentUserGroups.delete(groupId);
break; break;
case 'group-member-updated': case 'group-member-updated':
// content { // content {
// groupId: string, // groupId: string,
@@ -5054,6 +5087,7 @@ speechSynthesis.getVoices();
API.getCurrentUser().catch((err1) => { API.getCurrentUser().catch((err1) => {
throw err1; throw err1;
}); });
AppApi.CheckGameRunning();
} }
if (--this.nextAppUpdateCheck <= 0) { if (--this.nextAppUpdateCheck <= 0) {
if (this.branch === 'Stable') { if (this.branch === 'Stable') {
@@ -11725,6 +11759,12 @@ speechSynthesis.getVoices();
} else { } else {
var platform = 'VR'; var platform = 'VR';
} }
var groupAccessType = '';
if (L.groupAccessType) {
if (L.groupAccessType === 'public') {
groupAccessType = 'Public';
}
}
switch (L.accessType) { switch (L.accessType) {
case 'public': case 'public':
L.joinUrl = this.getLaunchURL(L); L.joinUrl = this.getLaunchURL(L);
@@ -11746,7 +11786,7 @@ speechSynthesis.getVoices();
L.accessName = `Group #${L.instanceName} (${platform})`; L.accessName = `Group #${L.instanceName} (${platform})`;
this.getGroupName(L.groupId).then((groupName) => { this.getGroupName(L.groupId).then((groupName) => {
if (groupName) { if (groupName) {
L.accessName = `Group(${groupName}) #${L.instanceName} (${platform})`; L.accessName = `Group${groupAccessType}(${groupName}) #${L.instanceName} (${platform})`;
} }
}); });
break; break;
@@ -15461,7 +15501,7 @@ speechSynthesis.getVoices();
json: {} json: {}
}; };
} }
if (L.isOffline || L.isPrivate || L.isTraveling || L.worldId === '') { if (!this.isRealInstance(L.tag)) {
D.instance = { D.instance = {
id: L.instanceId, id: L.instanceId,
tag: L.tag, tag: L.tag,
@@ -17474,11 +17514,11 @@ speechSynthesis.getVoices();
}; };
$app.methods.showInviteDialog = function (tag) { $app.methods.showInviteDialog = function (tag) {
this.$nextTick(() => adjustDialogZ(this.$refs.inviteDialog.$el)); if (!this.isRealInstance(tag)) {
var L = API.parseLocation(tag);
if (L.isOffline || L.isPrivate || L.isTraveling || L.worldId === '') {
return; return;
} }
this.$nextTick(() => adjustDialogZ(this.$refs.inviteDialog.$el));
var L = API.parseLocation(tag);
API.getCachedWorld({ API.getCachedWorld({
worldId: L.worldId worldId: L.worldId
}).then((args) => { }).then((args) => {
@@ -17668,6 +17708,7 @@ speechSynthesis.getVoices();
accessType: '', accessType: '',
region: '', region: '',
groupId: '', groupId: '',
groupAccessType: '',
strict: false, strict: false,
location: '', location: '',
shortName: '', shortName: '',
@@ -17700,6 +17741,7 @@ speechSynthesis.getVoices();
tags.push(`~friends(${userId})`); tags.push(`~friends(${userId})`);
} else if (D.accessType === 'group') { } else if (D.accessType === 'group') {
tags.push(`~group(${D.groupId})`); tags.push(`~group(${D.groupId})`);
tags.push(`~groupAccessType(${D.groupAccessType})`);
} else { } else {
tags.push(`~private(${userId})`); tags.push(`~private(${userId})`);
} }
@@ -17796,6 +17838,10 @@ speechSynthesis.getVoices();
'instanceDialogGroupId', 'instanceDialogGroupId',
this.newInstanceDialog.groupId this.newInstanceDialog.groupId
); );
configRepository.setString(
'instanceDialogGroupAccessType',
this.newInstanceDialog.groupAccessType
);
configRepository.setBool( configRepository.setBool(
'instanceDialogStrict', 'instanceDialogStrict',
this.newInstanceDialog.strict this.newInstanceDialog.strict
@@ -17812,40 +17858,29 @@ speechSynthesis.getVoices();
$app.watch['newInstanceDialog.strict'] = saveNewInstanceDialog; $app.watch['newInstanceDialog.strict'] = saveNewInstanceDialog;
$app.methods.showNewInstanceDialog = function (tag) { $app.methods.showNewInstanceDialog = function (tag) {
this.$nextTick(() => adjustDialogZ(this.$refs.newInstanceDialog.$el)); if (!this.isRealInstance(tag)) {
var L = API.parseLocation(tag);
if (L.isOffline || L.isPrivate || L.isTraveling || L.worldId === '') {
return; return;
} }
this.$nextTick(() => adjustDialogZ(this.$refs.newInstanceDialog.$el));
var D = this.newInstanceDialog; var D = this.newInstanceDialog;
var L = API.parseLocation(tag);
D.worldId = L.worldId; D.worldId = L.worldId;
D.accessType = 'public'; D.accessType = configRepository.getString(
if (configRepository.getString('instanceDialogAccessType') !== null) { 'instanceDialogAccessType',
D.accessType = configRepository.getString( 'public'
'instanceDialogAccessType' );
); D.region = configRepository.getString('instanceRegion', 'US West');
} D.instanceName = configRepository.getString(
D.region = 'US West'; 'instanceDialogInstanceName',
if (configRepository.getString('instanceRegion') !== null) { ''
D.region = configRepository.getString('instanceRegion'); );
} D.userId = configRepository.getString('instanceDialogUserId', '');
D.instanceName = ''; D.groupId = configRepository.getString('instanceDialogGroupId', '');
if (configRepository.getString('instanceDialogInstanceName') !== null) { D.groupAccessType = configRepository.getString(
D.instanceName = configRepository.getString( 'instanceDialogGroupAccessType',
'instanceDialogInstanceName' 'members'
); );
}
D.userId = '';
if (configRepository.getString('instanceDialogUserId') !== null) {
D.userId = configRepository.getString('instanceDialogUserId');
}
if (configRepository.getString('instanceDialogGroupId') !== null) {
D.groupId = configRepository.getString('instanceDialogGroupId');
}
D.strict = false; D.strict = false;
// if (configRepository.getBool('instanceDialogStrict') !== null) {
// D.strict = configRepository.getBool('instanceDialogStrict');
// }
D.shortName = ''; D.shortName = '';
this.buildInstance(); this.buildInstance();
this.updateNewInstanceDialog(); this.updateNewInstanceDialog();
@@ -18081,6 +18116,9 @@ speechSynthesis.getVoices();
}; };
$app.methods.showLaunchDialog = function (tag, shortName) { $app.methods.showLaunchDialog = function (tag, shortName) {
if (!this.isRealInstance(tag)) {
return;
}
this.$nextTick(() => adjustDialogZ(this.$refs.launchDialog.$el)); this.$nextTick(() => adjustDialogZ(this.$refs.launchDialog.$el));
var D = this.launchDialog; var D = this.launchDialog;
D.tag = tag; D.tag = tag;
@@ -18089,9 +18127,6 @@ speechSynthesis.getVoices();
D.shortName = shortName; D.shortName = shortName;
var L = API.parseLocation(tag); var L = API.parseLocation(tag);
L.shortName = shortName; L.shortName = shortName;
if (L.isOffline || L.isPrivate || L.isTraveling || L.worldId === '') {
return;
}
if (shortName) { if (shortName) {
D.shortUrl = `https://vrch.at/${shortName}`; D.shortUrl = `https://vrch.at/${shortName}`;
} }
@@ -21514,6 +21549,13 @@ speechSynthesis.getVoices();
userId userId
}; };
var args = await API.getGroups(params); var args = await API.getGroups(params);
if (userId === API.currentUser.id) {
// update current user groups
API.currentUserGroups.clear();
args.json.forEach((group) => {
API.currentUserGroups.set(group.id, group);
});
}
this.userGroups.groups = args.json; this.userGroups.groups = args.json;
for (var i = 0; i < args.json.length; ++i) { for (var i = 0; i < args.json.length; ++i) {
var group = args.json[i]; var group = args.json[i];
@@ -21540,6 +21582,15 @@ speechSynthesis.getVoices();
} }
}; };
$app.methods.getCurrentUserGroups = async function () {
var args = await API.getGroups({ n: 100, userId: API.currentUser.id });
this.inviteGroupDialog.groups = args.json;
API.currentUserGroups.clear();
args.json.forEach((group) => {
API.currentUserGroups.set(group.id, group);
});
};
$app.methods.sortCurrentUserGroups = function () { $app.methods.sortCurrentUserGroups = function () {
var groupList = []; var groupList = [];
var sortGroups = function (a, b) { var sortGroups = function (a, b) {
@@ -24350,6 +24401,7 @@ speechSynthesis.getVoices();
// #region | App: Groups // #region | App: Groups
API.cachedGroups = new Map(); API.cachedGroups = new Map();
API.currentUserGroups = new Map();
/* /*
params: { params: {
@@ -24375,6 +24427,9 @@ speechSynthesis.getVoices();
API.$on('GROUP', function (args) { API.$on('GROUP', function (args) {
args.ref = this.applyGroup(args.json); args.ref = this.applyGroup(args.json);
this.cachedGroups.set(args.ref.id, args.ref); this.cachedGroups.set(args.ref.id, args.ref);
if (this.currentUserGroups.has(args.ref.id)) {
this.currentUserGroups.set(args.ref.id, args.ref);
}
}); });
API.$on('GROUP', function (args) { API.$on('GROUP', function (args) {
@@ -24497,6 +24552,7 @@ speechSynthesis.getVoices();
$app.groupDialog.inGroup = json.membershipStatus === 'member'; $app.groupDialog.inGroup = json.membershipStatus === 'member';
$app.getGroupDialogGroup(groupId); $app.getGroupDialogGroup(groupId);
} }
this.currentUserGroups.set(groupId, json);
}); });
/* /*
@@ -24530,6 +24586,7 @@ speechSynthesis.getVoices();
) { ) {
$app.getCurrentUserRepresentedGroup(); $app.getCurrentUserRepresentedGroup();
} }
this.currentUserGroups.delete(groupId);
}); });
/* /*
@@ -25523,10 +25580,6 @@ speechSynthesis.getVoices();
}); });
this.isAllowedToInviteToGroup(); this.isAllowedToInviteToGroup();
} }
API.getGroups({ n: 100, userId: API.currentUser.id }).then((args) => {
this.inviteGroupDialog.groups = args.json;
D.loading = false;
});
if (userId) { if (userId) {
API.getCachedUser({ userId }).then((args) => { API.getCachedUser({ userId }).then((args) => {
+11 -1
View File
@@ -1156,6 +1156,10 @@ html
el-radio-button(label="friends") {{ $t('dialog.new_instance.access_type_friend') }} el-radio-button(label="friends") {{ $t('dialog.new_instance.access_type_friend') }}
el-radio-button(label="invite+") {{ $t('dialog.new_instance.access_type_invite_plus') }} el-radio-button(label="invite+") {{ $t('dialog.new_instance.access_type_invite_plus') }}
el-radio-button(label="invite") {{ $t('dialog.new_instance.access_type_invite') }} el-radio-button(label="invite") {{ $t('dialog.new_instance.access_type_invite') }}
el-form-item(:label="$t('dialog.new_instance.group_access_type')" v-if="newInstanceDialog.accessType === 'group'")
el-radio-group(v-model="newInstanceDialog.groupAccessType" size="mini" @change="buildInstance")
el-radio-button(label="members") {{ $t('dialog.new_instance.group_access_type_members') }}
el-radio-button(label="public") {{ $t('dialog.new_instance.group_access_type_public') }}
//- el-form-item(label="Strict" v-if="newInstanceDialog.accessType === 'friends' || newInstanceDialog.accessType === 'invite'") //- el-form-item(label="Strict" v-if="newInstanceDialog.accessType === 'friends' || newInstanceDialog.accessType === 'invite'")
//- el-checkbox(v-model="newInstanceDialog.strict") Prevent non friends joining via URL/Instance ID //- el-checkbox(v-model="newInstanceDialog.strict") Prevent non friends joining via URL/Instance ID
el-form-item(:label="$t('dialog.new_instance.region')") el-form-item(:label="$t('dialog.new_instance.region')")
@@ -1209,7 +1213,13 @@ html
span.name(v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}") span.name(v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}")
span(v-else v-text="friend.id") span(v-else v-text="friend.id")
el-form-item(:label="$t('dialog.new_instance.group_id')" v-if="newInstanceDialog.accessType === 'group'") el-form-item(:label="$t('dialog.new_instance.group_id')" v-if="newInstanceDialog.accessType === 'group'")
el-input(v-model="newInstanceDialog.groupId" placeholder="grp_UUID" size="mini") el-select(v-model="newInstanceDialog.groupId" clearable :placeholder="$t('dialog.new_instance.group_placeholder')" filterable style="width:100%")
el-option-group(:label="$t('dialog.new_instance.group_placeholder')")
el-option.x-friend-item(v-for="group in API.currentUserGroups.values()" :key="group.id" :label="group.name" :value="group.id" style="height:auto;width:478px")
.avatar
img(v-lazy="group.iconUrl")
.detail
span.name(v-text="group.name")
el-form-item(:label="$t('dialog.new_instance.location')") el-form-item(:label="$t('dialog.new_instance.location')")
el-input(v-model="newInstanceDialog.location" size="mini" readonly) el-input(v-model="newInstanceDialog.location" size="mini" readonly)
el-form-item(:label="$t('dialog.new_instance.url')") el-form-item(:label="$t('dialog.new_instance.url')")
+5 -1
View File
@@ -814,6 +814,9 @@
"access_type_friend": "Friends", "access_type_friend": "Friends",
"access_type_invite_plus": "Invite+", "access_type_invite_plus": "Invite+",
"access_type_invite": "Invite", "access_type_invite": "Invite",
"group_access_type": "Group Access",
"group_access_type_members": "Members",
"group_access_type_public": "Public",
"region": "Region", "region": "Region",
"region_usw": "US West", "region_usw": "US West",
"region_use": "US East", "region_use": "US East",
@@ -824,7 +827,8 @@
"instance_id_placeholder": "Random", "instance_id_placeholder": "Random",
"instance_creator": "Instance Creator", "instance_creator": "Instance Creator",
"instance_creator_placeholder": "Choose User", "instance_creator_placeholder": "Choose User",
"group_id": "Group ID", "group_placeholder": "Choose Group",
"group_id": "Group",
"location": "Location", "location": "Location",
"url": "URL", "url": "URL",
"copy_url": "Copy URL", "copy_url": "Copy URL",