mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-23 00:33:50 +02:00
refactor: Group Dialog (#1207)
This commit is contained in:
187
src/app.js
187
src/app.js
@@ -14,6 +14,7 @@ import Noty from 'noty';
|
||||
import Vue from 'vue';
|
||||
import VueLazyload from 'vue-lazyload';
|
||||
import VueI18n from 'vue-i18n';
|
||||
import { createI18n } from 'vue-i18n-bridge';
|
||||
import { DataTables } from 'vue-data-tables';
|
||||
import ElementUI from 'element-ui';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -49,7 +50,8 @@ import {
|
||||
inviteMessagesRequest,
|
||||
miscRequest,
|
||||
imageRequest,
|
||||
vrcPlusImageRequest
|
||||
vrcPlusImageRequest,
|
||||
groupRequest
|
||||
} from './classes/request';
|
||||
|
||||
// tabs
|
||||
@@ -75,6 +77,8 @@ import PreviousInstancesUserDialog from './views/dialogs/previousInstances/Previ
|
||||
import FavoriteDialog from './views/dialogs/favoritesDialog/FavoriteDialog.vue';
|
||||
import ExportFriendsListDialog from './views/dialogs/favoritesDialog/ExportFriendsListDialog.vue';
|
||||
import ExportAvatarsListDialog from './views/dialogs/favoritesDialog/ExportAvatarsListDialog.vue';
|
||||
import GroupDialog from './views/dialogs/groupDialog/GroupDialog.vue';
|
||||
import InviteGroupDialog from './views/dialogs/groupDialog/InviteGroupDialog.vue';
|
||||
|
||||
// main app classes
|
||||
import _sharedFeed from './classes/sharedFeed.js';
|
||||
@@ -136,16 +140,24 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
|
||||
// #region | localization
|
||||
Vue.use(VueI18n);
|
||||
const i18n = new VueI18n({
|
||||
locale: 'en',
|
||||
fallbackLocale: 'en',
|
||||
messages: localizedStrings,
|
||||
silentTranslationWarn: true
|
||||
});
|
||||
const $t = i18n.t.bind(i18n);
|
||||
Vue.use(VueI18n, { bridge: true });
|
||||
const i18n = createI18n(
|
||||
{
|
||||
locale: 'en',
|
||||
fallbackLocale: 'en',
|
||||
messages: localizedStrings,
|
||||
legacy: false,
|
||||
globalInjection: true,
|
||||
missingWarn: false,
|
||||
warnHtmlMessage: false,
|
||||
fallbackWarn: false
|
||||
},
|
||||
VueI18n
|
||||
);
|
||||
const $t = i18n.global.t;
|
||||
Vue.use(i18n);
|
||||
Vue.use(ElementUI, {
|
||||
i18n: (key, value) => i18n.t(key, value)
|
||||
i18n: (key, value) => i18n.global.t(key, value)
|
||||
});
|
||||
// #endregion
|
||||
|
||||
@@ -225,6 +237,9 @@ console.log(`isLinux: ${LINUX}`);
|
||||
PreviousInstancesUserDialog,
|
||||
// - world
|
||||
WorldDialog,
|
||||
// - group
|
||||
GroupDialog,
|
||||
InviteGroupDialog,
|
||||
// - favorites
|
||||
FriendImportDialog,
|
||||
WorldImportDialog,
|
||||
@@ -248,7 +263,6 @@ console.log(`isLinux: ${LINUX}`);
|
||||
userImageFull: this.userImageFull,
|
||||
showFullscreenImageDialog: this.showFullscreenImageDialog,
|
||||
statusClass: this.statusClass,
|
||||
getFaviconUrl: this.getFaviconUrl,
|
||||
openExternalLink: this.openExternalLink,
|
||||
beforeDialogClose: this.beforeDialogClose,
|
||||
dialogMouseDown: this.dialogMouseDown,
|
||||
@@ -260,7 +274,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
showInviteDialog: this.showInviteDialog,
|
||||
showLaunchDialog: this.showLaunchDialog,
|
||||
showFavoriteDialog: this.showFavoriteDialog,
|
||||
displayPreviousImages: this.displayPreviousImages
|
||||
displayPreviousImages: this.displayPreviousImages,
|
||||
languageClass: this.languageClass,
|
||||
showGroupDialog: this.showGroupDialog,
|
||||
showGallerySelectDialog: this.showGallerySelectDialog
|
||||
};
|
||||
},
|
||||
el: '#root',
|
||||
@@ -287,15 +304,9 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.enableAppLauncher,
|
||||
this.enableAppLauncherAutoClose
|
||||
);
|
||||
API.$on('SHOW_USER_DIALOG', (userId) =>
|
||||
this.showUserDialog(userId)
|
||||
);
|
||||
API.$on('SHOW_WORLD_DIALOG_SHORTNAME', (tag) =>
|
||||
this.verifyShortName('', tag)
|
||||
);
|
||||
API.$on('SHOW_GROUP_DIALOG', (groupId) =>
|
||||
this.showGroupDialog(groupId)
|
||||
);
|
||||
this.updateLoop();
|
||||
this.getGameLogTable();
|
||||
this.refreshCustomCss();
|
||||
@@ -4169,13 +4180,6 @@ console.log(`isLinux: ${LINUX}`);
|
||||
|
||||
$app.data.gameLogTable.pageSize = $app.data.tablePageSize;
|
||||
$app.data.feedTable.pageSize = $app.data.tablePageSize;
|
||||
$app.data.groupMemberModerationTable.pageSize = $app.data.tablePageSize;
|
||||
$app.data.groupBansModerationTable.pageSize = $app.data.tablePageSize;
|
||||
$app.data.groupLogsModerationTable.pageSize = $app.data.tablePageSize;
|
||||
$app.data.groupInvitesModerationTable.pageSize = $app.data.tablePageSize;
|
||||
$app.data.groupJoinRequestsModerationTable.pageSize =
|
||||
$app.data.tablePageSize;
|
||||
$app.data.groupBlockedModerationTable.pageSize = $app.data.tablePageSize;
|
||||
|
||||
$app.data.dontLogMeOut = false;
|
||||
|
||||
@@ -5559,11 +5563,22 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
}
|
||||
this.isSearchGroupLoading = true;
|
||||
await API.groupSearch(params)
|
||||
await groupRequest
|
||||
.groupSearch(params)
|
||||
.finally(() => {
|
||||
this.isSearchGroupLoading = false;
|
||||
})
|
||||
.then((args) => {
|
||||
// API.$on('GROUP:SEARCH', function (args) {
|
||||
for (const json of args.json) {
|
||||
API.$emit('GROUP', {
|
||||
json,
|
||||
params: {
|
||||
groupId: json.id
|
||||
}
|
||||
});
|
||||
}
|
||||
// });
|
||||
var map = new Map();
|
||||
for (var json of args.json) {
|
||||
var ref = API.cachedGroups.get(json.id);
|
||||
@@ -8263,8 +8278,18 @@ console.log(`isLinux: ${LINUX}`);
|
||||
};
|
||||
|
||||
$app.methods.showGroupDialogShortCode = function (shortCode) {
|
||||
API.groupStrictsearch({ query: shortCode }).then((args) => {
|
||||
for (var group of args.json) {
|
||||
groupRequest.groupStrictsearch({ query: shortCode }).then((args) => {
|
||||
for (const group of args.json) {
|
||||
// API.$on('GROUP:STRICTSEARCH', function (args) {
|
||||
// for (var json of args.json) {
|
||||
API.$emit('GROUP', {
|
||||
group,
|
||||
params: {
|
||||
groupId: group.id
|
||||
}
|
||||
});
|
||||
// }
|
||||
// });
|
||||
if (`${group.shortCode}.${group.discriminator}` === shortCode) {
|
||||
this.showGroupDialog(group.id);
|
||||
}
|
||||
@@ -8461,15 +8486,6 @@ console.log(`isLinux: ${LINUX}`);
|
||||
await this.sortCurrentUserGroups();
|
||||
};
|
||||
|
||||
$app.methods.getFaviconUrl = function (resource) {
|
||||
try {
|
||||
var url = new URL(resource);
|
||||
return `https://icons.duckduckgo.com/ip2/${url.host}.ico`;
|
||||
} catch (err) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
API.$on('LOGOUT', function () {
|
||||
$app.userDialog.visible = false;
|
||||
});
|
||||
@@ -8912,14 +8928,18 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
API.getRepresentedGroup({ userId }).then((args1) => {
|
||||
D.representedGroup = args1.json;
|
||||
D.representedGroup.$thumbnailUrl =
|
||||
this.getSmallThumbnailUrl(args1.json.iconUrl);
|
||||
if (!args1.json || !args1.json.isRepresenting) {
|
||||
D.isRepresentedGroupLoading = false;
|
||||
}
|
||||
});
|
||||
groupRequest
|
||||
.getRepresentedGroup({ userId })
|
||||
.then((args1) => {
|
||||
D.representedGroup = args1.json;
|
||||
D.representedGroup.$thumbnailUrl =
|
||||
this.getSmallThumbnailUrl(
|
||||
args1.json.iconUrl
|
||||
);
|
||||
if (!args1.json || !args1.json.isRepresenting) {
|
||||
D.isRepresentedGroupLoading = false;
|
||||
}
|
||||
});
|
||||
D.loading = false;
|
||||
});
|
||||
}
|
||||
@@ -10943,7 +10963,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.showSetAvatarTagsDialog(D.id);
|
||||
break;
|
||||
case 'Download Unity Package':
|
||||
$utils.openExternalLink(
|
||||
this.openExternalLink(
|
||||
this.replaceVrcPackageUrl(
|
||||
this.avatarDialog.ref.unityPackageUrl
|
||||
)
|
||||
@@ -11639,7 +11659,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
if (
|
||||
D.ageGate &&
|
||||
type === 'group' &&
|
||||
this.hasGroupPermission(
|
||||
$utils.hasGroupPermission(
|
||||
D.groupRef,
|
||||
'group-instance-age-gated-create'
|
||||
)
|
||||
@@ -12196,22 +12216,6 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.copyToClipboard(displayName);
|
||||
};
|
||||
|
||||
$app.methods.copyGroupId = function (groupId) {
|
||||
this.$message({
|
||||
message: 'Group ID copied to clipboard',
|
||||
type: 'success'
|
||||
});
|
||||
this.copyToClipboard(groupId);
|
||||
};
|
||||
|
||||
$app.methods.copyGroupUrl = function (groupUrl) {
|
||||
this.$message({
|
||||
message: 'Group URL copied to clipboard',
|
||||
type: 'success'
|
||||
});
|
||||
this.copyToClipboard(groupUrl);
|
||||
};
|
||||
|
||||
$app.methods.copyImageUrl = function (imageUrl) {
|
||||
this.$message({
|
||||
message: 'ImageUrl copied to clipboard',
|
||||
@@ -15134,6 +15138,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
return style;
|
||||
};
|
||||
|
||||
// TODO: launch, invite, refresh, etc. buttons, better to split into one component
|
||||
$app.methods.refreshInstancePlayerCount = function (instance) {
|
||||
var L = $utils.parseLocation(instance);
|
||||
if (L.isRealInstance) {
|
||||
@@ -15161,7 +15166,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
mutualGroups: [],
|
||||
remainingGroups: []
|
||||
};
|
||||
var args = await API.getGroups({ userId });
|
||||
var args = await groupRequest.getGroups({ userId });
|
||||
if (userId !== this.userDialog.id) {
|
||||
this.userDialog.isGroupsLoading = false;
|
||||
return;
|
||||
@@ -18649,6 +18654,8 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
};
|
||||
|
||||
// use in avatar, user, group dialog
|
||||
// TODO: better in utils
|
||||
$app.methods.downloadAndSaveJson = function (fileName, data) {
|
||||
if (!fileName || !data) {
|
||||
return;
|
||||
@@ -18752,6 +18759,9 @@ console.log(`isLinux: ${LINUX}`);
|
||||
};
|
||||
};
|
||||
|
||||
$app.data.groupDialogSortingOptions = {};
|
||||
$app.data.groupDialogFilterOptions = {};
|
||||
|
||||
$app.methods.applyGroupDialogSortingStrings = function () {
|
||||
this.groupDialogSortingOptions = {
|
||||
joinedAtDesc: {
|
||||
@@ -19299,7 +19309,6 @@ console.log(`isLinux: ${LINUX}`);
|
||||
hideTooltips: this.hideTooltips,
|
||||
randomUserColours: this.randomUserColours,
|
||||
sortStatus: this.sortStatus,
|
||||
languageClass: this.languageClass,
|
||||
confirmDeleteFriend: this.confirmDeleteFriend,
|
||||
friendsListSearch: this.friendsListSearch,
|
||||
stringComparer: this.stringComparer
|
||||
@@ -19626,6 +19635,54 @@ console.log(`isLinux: ${LINUX}`);
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.groupDialogBind = function () {
|
||||
return {
|
||||
'group-dialog': this.groupDialog,
|
||||
'hide-tooltips': this.hideTooltips,
|
||||
'last-location': this.lastLocation,
|
||||
'update-instance-info': this.updateInstanceInfo,
|
||||
'group-dialog-sorting-options': this.groupDialogSortingOptions,
|
||||
'group-dialog-filter-options': this.groupDialogFilterOptions,
|
||||
'is-group-gallery-loading': this.isGroupGalleryLoading,
|
||||
'gallery-select-dialog': this.gallerySelectDialog,
|
||||
'random-user-colours': this.randomUserColours
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.groupDialogEvent = function () {
|
||||
return {
|
||||
'refresh-instance-player-count': this.refreshInstancePlayerCount,
|
||||
'update-group-post-search': this.updateGroupPostSearch,
|
||||
'download-and-save-json': this.downloadAndSaveJson,
|
||||
'group-dialog-command': this.groupDialogCommand,
|
||||
'get-group-dialog-group': this.getGroupDialogGroup,
|
||||
'clear-image-gallery-select': this.clearImageGallerySelect,
|
||||
'update:gallery-select-dialog': (val) =>
|
||||
(this.gallerySelectDialog = val),
|
||||
'update:group-dialog': (val) => {
|
||||
this.groupDialog = val;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.inviteGroupDialogBind = function () {
|
||||
return {
|
||||
'dialog-data': this.inviteGroupDialog,
|
||||
'vip-friends': this.vipFriends,
|
||||
'online-friends': this.onlineFriends,
|
||||
'offline-friends': this.offlineFriends,
|
||||
'active-friends': this.activeFriends
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.inviteGroupDialogEvent = function () {
|
||||
return {
|
||||
'update:dialog-data': (val) => {
|
||||
this.inviteGroupDialog = val;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region | Electron
|
||||
|
||||
Reference in New Issue
Block a user