Skip to content

Commit

Permalink
Update new instance dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed May 3, 2024
1 parent 7761d85 commit 4718b98
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 80 deletions.
166 changes: 130 additions & 36 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5096,6 +5096,10 @@ speechSynthesis.getVoices();
if ($app.galleryDialogVisible) {
$app.refreshEmojiTable();
}
} else if (contentType === 'avatar') {
// hmm, utilizing this might be too spamy and cause UI to move around
} else if (contentType === 'world') {
// hmm
} else {
console.log('Unknown content-refresh', content);
}
Expand Down Expand Up @@ -20003,14 +20007,15 @@ speechSynthesis.getVoices();
secureOrShortName: '',
lastSelectedGroupId: '',
selectedGroupRoles: [],
roleIds: []
roleIds: [],
groupRef: {}
};

API.$on('LOGOUT', function () {
$app.newInstanceDialog.visible = false;
});

$app.methods.buildInstance = function () {
$app.methods.buildLegacyInstance = function () {
var D = this.newInstanceDialog;
D.instanceCreated = false;
D.shortName = '';
Expand Down Expand Up @@ -20061,6 +20066,7 @@ speechSynthesis.getVoices();
D.roleIds = [];
var ref = API.cachedGroups.get(D.groupId);
if (typeof ref !== 'undefined') {
D.groupRef = ref;
D.selectedGroupRoles = ref.roles;
API.getGroupRoles({
groupId: D.groupId
Expand All @@ -20074,19 +20080,73 @@ speechSynthesis.getVoices();
if (!D.groupId) {
D.roleIds = [];
D.selectedGroupRoles = [];
D.groupRef = {};
D.lastSelectedGroupId = '';
}
D.instanceId = tags.join('');
this.updateNewInstanceDialog(false);
this.saveNewInstanceDialog();
};

$app.methods.createGroupInstance = function () {
$app.methods.buildInstance = function () {
var D = this.newInstanceDialog;
D.instanceCreated = false;
D.instanceId = '';
D.shortName = '';
D.secureOrShortName = '';
if (!D.userId) {
D.userId = API.currentUser.id;
}
if (D.groupId && D.groupId !== D.lastSelectedGroupId) {
D.roleIds = [];
var ref = API.cachedGroups.get(D.groupId);
if (typeof ref !== 'undefined') {
D.groupRef = ref;
D.selectedGroupRoles = ref.roles;
API.getGroupRoles({
groupId: D.groupId
}).then((args) => {
D.lastSelectedGroupId = D.groupId;
D.selectedGroupRoles = args.json;
ref.roles = args.json;
});
}
}
if (!D.groupId) {
D.roleIds = [];
D.groupRef = {};
D.selectedGroupRoles = [];
D.lastSelectedGroupId = '';
}
this.saveNewInstanceDialog();
};

$app.methods.createNewInstance = function () {
var D = this.newInstanceDialog;
if (D.loading) {
return;
}
D.loading = true;
var type = 'public';
var canRequestInvite = false;
switch (D.accessType) {
case 'friends':
type = 'friends';
break;
case 'friends+':
type = 'hidden';
break;
case 'invite':
type = 'private';
break;
case 'invite+':
type = 'private';
canRequestInvite = true;
break;
case 'group':
type = 'group';
break;
}
var region = 'us';
if (D.region === 'US East') {
region = 'use';
Expand All @@ -20095,19 +20155,22 @@ speechSynthesis.getVoices();
} else if (D.region === 'Japan') {
region = 'jp';
}
var roleIds = [];
if (D.groupAccessType === 'member') {
roleIds = D.roleIds;
}
API.createInstance({
type: 'group',
groupAccessType: D.groupAccessType,
var params = {
type,
canRequestInvite,
worldId: D.worldId,
ownerId: D.groupId,
region,
queueEnabled: D.queueEnabled,
roleIds
})
ownerId: D.userId,
region
};
if (type === 'group') {
params.groupAccessType = D.groupAccessType;
params.ownerId = D.groupId;
params.queueEnabled = D.queueEnabled;
if (D.groupAccessType === 'member') {
params.roleIds = D.roleIds;
}
}
API.createInstance(params)
.then((args) => {
D.location = args.json.location;
D.instanceId = args.json.instanceId;
Expand Down Expand Up @@ -20173,10 +20236,6 @@ speechSynthesis.getVoices();
'instanceRegion',
this.newInstanceDialog.region
);
await configRepository.setString(
'groupInstanceRegion',
this.newInstanceDialog.groupRegion
);
await configRepository.setString(
'instanceDialogInstanceName',
this.newInstanceDialog.instanceName
Expand Down Expand Up @@ -20214,6 +20273,11 @@ speechSynthesis.getVoices();
this.$nextTick(() => adjustDialogZ(this.$refs.newInstanceDialog.$el));
var D = this.newInstanceDialog;
var L = API.parseLocation(tag);
if (D.worldId === L.worldId) {
// reopening dialog, keep last open instance
D.visible = true;
return;
}
D.worldId = L.worldId;
D.accessType = await configRepository.getString(
'instanceDialogAccessType',
Expand All @@ -20223,10 +20287,6 @@ speechSynthesis.getVoices();
'instanceRegion',
'US West'
);
D.groupRegion = await configRepository.getString(
'groupInstanceRegion',
'US West'
);
D.instanceName = await configRepository.getString(
'instanceDialogInstanceName',
''
Expand All @@ -20247,11 +20307,17 @@ speechSynthesis.getVoices();
D.instanceCreated = false;
D.lastSelectedGroupId = '';
D.selectedGroupRoles = [];
D.groupRef = {};
D.roleIds = [];
D.strict = false;
D.shortName = '';
D.secureOrShortName = '';
this.buildInstance();
API.getGroupPermissions({ userId: API.currentUser.id });
if (D.selectedTab === '0') {
this.buildInstance();
} else {
this.buildLegacyInstance();
}
this.updateNewInstanceDialog();
D.visible = true;
};
Expand Down Expand Up @@ -24525,6 +24591,7 @@ speechSynthesis.getVoices();
var ref = API.applyGroup(group);
API.currentUserGroups.set(group.id, ref);
});
await API.getGroupPermissions({ userId: API.currentUser.id });
this.saveCurrentUserGroups();
};

Expand Down Expand Up @@ -28371,7 +28438,34 @@ speechSynthesis.getVoices();
}
});

//**
API.getGroupPermissions = function (params) {
return this.call(`users/${params.userId}/groups/permissions`, {
method: 'GET'
}).then((json) => {
var args = {
json,
params
};
this.$emit('GROUP:PERMISSIONS', args);
return args;
});
};

API.$on('GROUP:PERMISSIONS', function (args) {
if (args.params.userId !== this.currentUser.id) {
return;
}
var json = args.json;
for (var groupId in json) {
var permissions = json[groupId];
var group = this.cachedGroups.get(groupId);
if (group) {
group.myMember.permissions = permissions;
}
}
});

// /**
// * @param {{ groupId: string }} params
// * @return { Promise<{json: any, params}> }
// */
Expand Down Expand Up @@ -28866,8 +28960,6 @@ speechSynthesis.getVoices();
var ref = this.applyGroupMember(json);
$app.groupBansModerationTable.data.push(ref);
}
// $app.groupBansModerationTable.data =
// $app.groupBansModerationTable.data.concat(args.json);
});

$app.methods.getAllGroupLogs = async function (groupId) {
Expand Down Expand Up @@ -30108,6 +30200,17 @@ speechSynthesis.getVoices();
await this.getGroupDialogGroupMembers();
};

$app.methods.getCurrentUserRepresentedGroup = function () {
return API.getRepresentedGroup({
userId: API.currentUser.id
}).then((args) => {
this.userDialog.representedGroup = args.json;
return args;
});
};

// group permissions

$app.methods.hasGroupPermission = function (ref, permission) {
if (
ref &&
Expand All @@ -30121,15 +30224,6 @@ speechSynthesis.getVoices();
return false;
};

$app.methods.getCurrentUserRepresentedGroup = function () {
return API.getRepresentedGroup({
userId: API.currentUser.id
}).then((args) => {
this.userDialog.representedGroup = args.json;
return args;
});
};

// group gallery

$app.data.isGroupGalleryLoading = false;
Expand Down
4 changes: 4 additions & 0 deletions html/src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
-webkit-line-clamp: 1;
}

.notification-table .el-table .cell {
-webkit-line-clamp: 2;
}

.el-table__row:hover .el-table__cell .cell {
-webkit-line-clamp: unset;
}
Expand Down
Loading

0 comments on commit 4718b98

Please sign in to comment.