mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-04 22:06:06 +02:00
refactor: import dialogs (#1187)
* refactor: import dialogs * fix: world dialog z-index issue * fix: world dialog z-index issue
This commit is contained in:
+149
-548
@@ -67,6 +67,9 @@ import Location from './components/common/Location.vue';
|
||||
// dialogs
|
||||
import WorldDialog from './views/dialogs/WorldDialog.vue';
|
||||
import PreviousInstanceInfoDialog from './views/dialogs/PreviousInstanceInfoDialog.vue';
|
||||
import FriendImportDialog from './views/dialogs/FriendImportDialog.vue';
|
||||
import WorldImportDialog from './views/dialogs/WorldImportDialog.vue';
|
||||
import AvatarImportDialog from './views/dialogs/AvatarImportDialog.vue';
|
||||
|
||||
// main app classes
|
||||
import _sharedFeed from './classes/sharedFeed.js';
|
||||
@@ -213,7 +216,11 @@ console.log(`isLinux: ${LINUX}`);
|
||||
|
||||
// - dialogs
|
||||
PreviousInstanceInfoDialog,
|
||||
WorldDialog
|
||||
WorldDialog,
|
||||
// - import dialogs
|
||||
FriendImportDialog,
|
||||
WorldImportDialog,
|
||||
AvatarImportDialog
|
||||
},
|
||||
provide() {
|
||||
return {
|
||||
@@ -228,7 +235,12 @@ console.log(`isLinux: ${LINUX}`);
|
||||
showFullscreenImageDialog: this.showFullscreenImageDialog,
|
||||
statusClass: this.statusClass,
|
||||
getFaviconUrl: this.getFaviconUrl,
|
||||
openExternalLink: this.openExternalLink
|
||||
openExternalLink: this.openExternalLink,
|
||||
beforeDialogClose: this.beforeDialogClose,
|
||||
dialogMouseDown: this.dialogMouseDown,
|
||||
dialogMouseUp: this.dialogMouseUp,
|
||||
showWorldDialog: this.showWorldDialog,
|
||||
showAvatarDialog: this.showAvatarDialog
|
||||
};
|
||||
},
|
||||
el: '#root',
|
||||
@@ -258,7 +270,6 @@ console.log(`isLinux: ${LINUX}`);
|
||||
API.$on('SHOW_USER_DIALOG', (userId) =>
|
||||
this.showUserDialog(userId)
|
||||
);
|
||||
API.$on('SHOW_WORLD_DIALOG', (tag) => this.showWorldDialog(tag));
|
||||
API.$on('SHOW_WORLD_DIALOG_SHORTNAME', (tag) =>
|
||||
this.verifyShortName('', tag)
|
||||
);
|
||||
@@ -396,7 +407,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
observer: true,
|
||||
observerOptions: {
|
||||
rootMargin: '0px',
|
||||
threshold: 0.1
|
||||
threshold: 0
|
||||
},
|
||||
attempt: 3
|
||||
});
|
||||
@@ -11377,42 +11388,6 @@ console.log(`isLinux: ${LINUX}`);
|
||||
});
|
||||
};
|
||||
|
||||
$app.methods.addFavoriteWorld = function (ref, group, message) {
|
||||
return favoriteRequest
|
||||
.addFavorite({
|
||||
type: 'world',
|
||||
favoriteId: ref.id,
|
||||
tags: group.name
|
||||
})
|
||||
.then((args) => {
|
||||
if (message) {
|
||||
this.$message({
|
||||
message: 'World added to favorites',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
return args;
|
||||
});
|
||||
};
|
||||
|
||||
$app.methods.addFavoriteUser = function (ref, group, message) {
|
||||
return favoriteRequest
|
||||
.addFavorite({
|
||||
type: 'friend',
|
||||
favoriteId: ref.id,
|
||||
tags: group.name
|
||||
})
|
||||
.then((args) => {
|
||||
if (message) {
|
||||
this.$message({
|
||||
message: 'Friend added to favorites',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
return args;
|
||||
});
|
||||
};
|
||||
|
||||
$app.methods.showFavoriteDialog = function (type, objectId) {
|
||||
this.$nextTick(() => $app.adjustDialogZ(this.$refs.favoriteDialog.$el));
|
||||
var D = this.favoriteDialog;
|
||||
@@ -16984,12 +16959,31 @@ console.log(`isLinux: ${LINUX}`);
|
||||
return false;
|
||||
};
|
||||
|
||||
$app.methods.userImage = function (user, isIcon, resolution = '64') {
|
||||
/**
|
||||
* @param {object} user - User Ref Object
|
||||
* @param {boolean} isIcon - is use for icon (about 40x40)
|
||||
* @param {string} resolution - requested icon resolution (default 128),
|
||||
* @param {boolean} isUserDialogIcon - is use for user dialog icon
|
||||
* @returns {string} - img url
|
||||
*
|
||||
* VRC's 64 scaling doesn't look good, 128 is better, but some images might be overly sharp.
|
||||
* 128 is smaller than 256 or the original image size, making it a good choice.
|
||||
*
|
||||
* TODO: code is messy cause I haven't figured out the img field, maybe refactor it later
|
||||
*/
|
||||
$app.methods.userImage = function (
|
||||
user,
|
||||
isIcon,
|
||||
resolution = '128',
|
||||
isUserDialogIcon = false
|
||||
) {
|
||||
if (!user) {
|
||||
return '';
|
||||
}
|
||||
// Only VRC+ icon users have the userIcon field ?
|
||||
if (this.displayVRCPlusIconsAsAvatar && user.userIcon) {
|
||||
if (
|
||||
(isUserDialogIcon && user.userIcon) ||
|
||||
(this.displayVRCPlusIconsAsAvatar && user.userIcon)
|
||||
) {
|
||||
if (isIcon) {
|
||||
const baseUrl = user.userIcon.replace('/file/', '/image/');
|
||||
return user.userIcon.endsWith('/')
|
||||
@@ -16998,6 +16992,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
return user.userIcon;
|
||||
}
|
||||
|
||||
if (user.profilePicOverrideThumbnail) {
|
||||
if (isIcon) {
|
||||
return user.profilePicOverrideThumbnail.replace(
|
||||
@@ -17013,13 +17008,28 @@ console.log(`isLinux: ${LINUX}`);
|
||||
if (user.thumbnailUrl) {
|
||||
return user.thumbnailUrl;
|
||||
}
|
||||
if (isIcon && user.currentAvatarThumbnailImageUrl) {
|
||||
return user.currentAvatarThumbnailImageUrl.replace(
|
||||
'256',
|
||||
resolution
|
||||
);
|
||||
if (user.currentAvatarThumbnailImageUrl) {
|
||||
if (isIcon) {
|
||||
return user.currentAvatarThumbnailImageUrl.replace(
|
||||
'256',
|
||||
resolution
|
||||
);
|
||||
}
|
||||
return user.currentAvatarThumbnailImageUrl;
|
||||
}
|
||||
return user.currentAvatarThumbnailImageUrl || '';
|
||||
if (user.currentAvatarImageUrl) {
|
||||
if (isIcon) {
|
||||
const baseUrl = user.currentAvatarImageUrl.replace(
|
||||
'/file/',
|
||||
'/image/'
|
||||
);
|
||||
const url = baseUrl.split('/');
|
||||
url[url.length - 1] = resolution;
|
||||
return url.join('/');
|
||||
}
|
||||
return user.currentAvatarImageUrl;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
$app.methods.userImageFull = function (user) {
|
||||
@@ -17431,14 +17441,14 @@ console.log(`isLinux: ${LINUX}`);
|
||||
if (!type) break;
|
||||
var data = input.replace(`import/${type}/`, '');
|
||||
if (type === 'avatar') {
|
||||
this.avatarImportDialogInput = data;
|
||||
this.showAvatarImportDialog();
|
||||
this.avatarImportDialog.input = data;
|
||||
} else if (type === 'world') {
|
||||
this.worldImportDialogInput = data;
|
||||
this.showWorldImportDialog();
|
||||
this.worldImportDialog.input = data;
|
||||
} else if (type === 'friend') {
|
||||
this.friendImportDialogInput = data;
|
||||
this.showFriendImportDialog();
|
||||
this.friendImportDialog.input = data;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -18148,488 +18158,29 @@ console.log(`isLinux: ${LINUX}`);
|
||||
// #endregion
|
||||
// #region | App: world favorite import
|
||||
|
||||
$app.data.worldImportDialog = {
|
||||
visible: false,
|
||||
loading: false,
|
||||
progress: 0,
|
||||
progressTotal: 0,
|
||||
input: '',
|
||||
worldIdList: new Set(),
|
||||
errors: '',
|
||||
worldImportFavoriteGroup: null,
|
||||
worldImportLocalFavoriteGroup: null,
|
||||
importProgress: 0,
|
||||
importProgressTotal: 0
|
||||
};
|
||||
|
||||
$app.data.worldImportTable = {
|
||||
data: [],
|
||||
tableProps: {
|
||||
stripe: true,
|
||||
size: 'mini'
|
||||
},
|
||||
layout: 'table'
|
||||
};
|
||||
|
||||
$app.data.worldImportDialogVisible = false;
|
||||
$app.data.worldImportDialogInput = '';
|
||||
$app.methods.showWorldImportDialog = function () {
|
||||
this.$nextTick(() =>
|
||||
$app.adjustDialogZ(this.$refs.worldImportDialog.$el)
|
||||
);
|
||||
var D = this.worldImportDialog;
|
||||
this.resetWorldImport();
|
||||
D.visible = true;
|
||||
this.worldImportDialogVisible = true;
|
||||
};
|
||||
|
||||
$app.methods.processWorldImportList = async function () {
|
||||
var D = this.worldImportDialog;
|
||||
D.loading = true;
|
||||
var regexWorldId =
|
||||
/wrld_[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}/g;
|
||||
var match = [];
|
||||
var worldIdList = new Set();
|
||||
while ((match = regexWorldId.exec(D.input)) !== null) {
|
||||
worldIdList.add(match[0]);
|
||||
}
|
||||
D.input = '';
|
||||
D.errors = '';
|
||||
D.progress = 0;
|
||||
D.progressTotal = worldIdList.size;
|
||||
var data = Array.from(worldIdList);
|
||||
for (var i = 0; i < data.length; ++i) {
|
||||
if (!D.visible) {
|
||||
this.resetWorldImport();
|
||||
}
|
||||
if (!D.loading || !D.visible) {
|
||||
break;
|
||||
}
|
||||
var worldId = data[i];
|
||||
if (!D.worldIdList.has(worldId)) {
|
||||
try {
|
||||
var args = await worldRequest.getWorld({
|
||||
worldId
|
||||
});
|
||||
this.worldImportTable.data.push(args.ref);
|
||||
D.worldIdList.add(worldId);
|
||||
} catch (err) {
|
||||
D.errors = D.errors.concat(
|
||||
`WorldId: ${worldId}\n${err}\n\n`
|
||||
);
|
||||
}
|
||||
}
|
||||
D.progress++;
|
||||
if (D.progress === worldIdList.size) {
|
||||
D.progress = 0;
|
||||
}
|
||||
}
|
||||
D.loading = false;
|
||||
};
|
||||
|
||||
$app.methods.deleteItemWorldImport = function (ref) {
|
||||
var D = this.worldImportDialog;
|
||||
$app.removeFromArray(this.worldImportTable.data, ref);
|
||||
D.worldIdList.delete(ref.id);
|
||||
};
|
||||
|
||||
$app.methods.resetWorldImport = function () {
|
||||
var D = this.worldImportDialog;
|
||||
D.input = '';
|
||||
D.errors = '';
|
||||
};
|
||||
|
||||
$app.methods.clearWorldImportTable = function () {
|
||||
var D = this.worldImportDialog;
|
||||
this.worldImportTable.data = [];
|
||||
D.worldIdList = new Set();
|
||||
};
|
||||
|
||||
$app.methods.selectWorldImportGroup = function (group) {
|
||||
var D = this.worldImportDialog;
|
||||
D.worldImportLocalFavoriteGroup = null;
|
||||
D.worldImportFavoriteGroup = group;
|
||||
};
|
||||
|
||||
$app.methods.selectWorldImportLocalGroup = function (group) {
|
||||
var D = this.worldImportDialog;
|
||||
D.worldImportFavoriteGroup = null;
|
||||
D.worldImportLocalFavoriteGroup = group;
|
||||
};
|
||||
|
||||
$app.methods.cancelWorldImport = function () {
|
||||
var D = this.worldImportDialog;
|
||||
D.loading = false;
|
||||
};
|
||||
|
||||
$app.methods.importWorldImportTable = async function () {
|
||||
var D = this.worldImportDialog;
|
||||
if (!D.worldImportFavoriteGroup && !D.worldImportLocalFavoriteGroup) {
|
||||
return;
|
||||
}
|
||||
D.loading = true;
|
||||
var data = [...this.worldImportTable.data].reverse();
|
||||
D.importProgressTotal = data.length;
|
||||
try {
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
if (!D.loading || !D.visible) {
|
||||
break;
|
||||
}
|
||||
var ref = data[i];
|
||||
if (D.worldImportFavoriteGroup) {
|
||||
await this.addFavoriteWorld(
|
||||
ref,
|
||||
D.worldImportFavoriteGroup,
|
||||
false
|
||||
);
|
||||
} else if (D.worldImportLocalFavoriteGroup) {
|
||||
this.addLocalWorldFavorite(
|
||||
ref.id,
|
||||
D.worldImportLocalFavoriteGroup
|
||||
);
|
||||
}
|
||||
$app.removeFromArray(this.worldImportTable.data, ref);
|
||||
D.worldIdList.delete(ref.id);
|
||||
D.importProgress++;
|
||||
}
|
||||
} catch (err) {
|
||||
D.errors = `Name: ${ref.name}\nWorldId: ${ref.id}\n${err}\n\n`;
|
||||
} finally {
|
||||
D.importProgress = 0;
|
||||
D.importProgressTotal = 0;
|
||||
D.loading = false;
|
||||
}
|
||||
};
|
||||
|
||||
API.$on('LOGIN', function () {
|
||||
$app.clearWorldImportTable();
|
||||
$app.resetWorldImport();
|
||||
$app.worldImportDialog.visible = false;
|
||||
$app.worldImportFavoriteGroup = null;
|
||||
$app.worldImportLocalFavoriteGroup = null;
|
||||
});
|
||||
|
||||
// #endregion
|
||||
// #region | App: avatar favorite import
|
||||
|
||||
$app.data.avatarImportDialog = {
|
||||
visible: false,
|
||||
loading: false,
|
||||
progress: 0,
|
||||
progressTotal: 0,
|
||||
input: '',
|
||||
avatarIdList: new Set(),
|
||||
errors: '',
|
||||
avatarImportFavoriteGroup: null,
|
||||
avatarImportLocalFavoriteGroup: null,
|
||||
importProgress: 0,
|
||||
importProgressTotal: 0
|
||||
};
|
||||
|
||||
$app.data.avatarImportTable = {
|
||||
data: [],
|
||||
tableProps: {
|
||||
stripe: true,
|
||||
size: 'mini'
|
||||
},
|
||||
layout: 'table'
|
||||
};
|
||||
|
||||
$app.data.avatarImportDialogVisible = false;
|
||||
$app.data.avatarImportDialogInput = '';
|
||||
$app.methods.showAvatarImportDialog = function () {
|
||||
this.$nextTick(() =>
|
||||
$app.adjustDialogZ(this.$refs.avatarImportDialog.$el)
|
||||
);
|
||||
var D = this.avatarImportDialog;
|
||||
this.resetAvatarImport();
|
||||
D.visible = true;
|
||||
this.avatarImportDialogVisible = true;
|
||||
};
|
||||
|
||||
$app.methods.processAvatarImportList = async function () {
|
||||
var D = this.avatarImportDialog;
|
||||
D.loading = true;
|
||||
var regexAvatarId =
|
||||
/avtr_[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}/g;
|
||||
var match = [];
|
||||
var avatarIdList = new Set();
|
||||
while ((match = regexAvatarId.exec(D.input)) !== null) {
|
||||
avatarIdList.add(match[0]);
|
||||
}
|
||||
D.input = '';
|
||||
D.errors = '';
|
||||
D.progress = 0;
|
||||
D.progressTotal = avatarIdList.size;
|
||||
var data = Array.from(avatarIdList);
|
||||
for (var i = 0; i < data.length; ++i) {
|
||||
if (!D.visible) {
|
||||
this.resetAvatarImport();
|
||||
}
|
||||
if (!D.loading || !D.visible) {
|
||||
break;
|
||||
}
|
||||
var avatarId = data[i];
|
||||
if (!D.avatarIdList.has(avatarId)) {
|
||||
try {
|
||||
var args = await avatarRequest.getAvatar({
|
||||
avatarId
|
||||
});
|
||||
this.avatarImportTable.data.push(args.ref);
|
||||
D.avatarIdList.add(avatarId);
|
||||
} catch (err) {
|
||||
D.errors = D.errors.concat(
|
||||
`AvatarId: ${avatarId}\n${err}\n\n`
|
||||
);
|
||||
}
|
||||
}
|
||||
D.progress++;
|
||||
if (D.progress === avatarIdList.size) {
|
||||
D.progress = 0;
|
||||
}
|
||||
}
|
||||
D.loading = false;
|
||||
};
|
||||
|
||||
$app.methods.deleteItemAvatarImport = function (ref) {
|
||||
var D = this.avatarImportDialog;
|
||||
$app.removeFromArray(this.avatarImportTable.data, ref);
|
||||
D.avatarIdList.delete(ref.id);
|
||||
};
|
||||
|
||||
$app.methods.resetAvatarImport = function () {
|
||||
var D = this.avatarImportDialog;
|
||||
D.input = '';
|
||||
D.errors = '';
|
||||
};
|
||||
|
||||
$app.methods.clearAvatarImportTable = function () {
|
||||
var D = this.avatarImportDialog;
|
||||
this.avatarImportTable.data = [];
|
||||
D.avatarIdList = new Set();
|
||||
};
|
||||
|
||||
$app.methods.selectAvatarImportGroup = function (group) {
|
||||
var D = this.avatarImportDialog;
|
||||
D.avatarImportLocalFavoriteGroup = null;
|
||||
D.avatarImportFavoriteGroup = group;
|
||||
};
|
||||
|
||||
$app.methods.selectAvatarImportLocalGroup = function (group) {
|
||||
var D = this.avatarImportDialog;
|
||||
D.avatarImportFavoriteGroup = null;
|
||||
D.avatarImportLocalFavoriteGroup = group;
|
||||
};
|
||||
|
||||
$app.methods.cancelAvatarImport = function () {
|
||||
var D = this.avatarImportDialog;
|
||||
D.loading = false;
|
||||
};
|
||||
|
||||
$app.methods.importAvatarImportTable = async function () {
|
||||
const addFavoriteAvatar = function (ref, group, message) {
|
||||
return favoriteRequest
|
||||
.addFavorite({
|
||||
type: 'avatar',
|
||||
favoriteId: ref.id,
|
||||
tags: group.name
|
||||
})
|
||||
.then((args) => {
|
||||
if (message) {
|
||||
this.$message({
|
||||
message: 'Avatar added to favorites',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
return args;
|
||||
});
|
||||
};
|
||||
var D = this.avatarImportDialog;
|
||||
if (!D.avatarImportFavoriteGroup && !D.avatarImportLocalFavoriteGroup) {
|
||||
return;
|
||||
}
|
||||
D.loading = true;
|
||||
var data = [...this.avatarImportTable.data].reverse();
|
||||
D.importProgressTotal = data.length;
|
||||
try {
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
if (!D.loading || !D.visible) {
|
||||
break;
|
||||
}
|
||||
var ref = data[i];
|
||||
if (D.avatarImportFavoriteGroup) {
|
||||
await addFavoriteAvatar(
|
||||
ref,
|
||||
D.avatarImportFavoriteGroup,
|
||||
false
|
||||
);
|
||||
} else if (D.avatarImportLocalFavoriteGroup) {
|
||||
this.addLocalAvatarFavorite(
|
||||
ref.id,
|
||||
D.avatarImportLocalFavoriteGroup
|
||||
);
|
||||
}
|
||||
$app.removeFromArray(this.avatarImportTable.data, ref);
|
||||
D.avatarIdList.delete(ref.id);
|
||||
D.importProgress++;
|
||||
}
|
||||
} catch (err) {
|
||||
D.errors = `Name: ${ref.name}\nAvatarId: ${ref.id}\n${err}\n\n`;
|
||||
} finally {
|
||||
D.importProgress = 0;
|
||||
D.importProgressTotal = 0;
|
||||
D.loading = false;
|
||||
}
|
||||
};
|
||||
|
||||
API.$on('LOGIN', function () {
|
||||
$app.clearAvatarImportTable();
|
||||
$app.resetAvatarImport();
|
||||
$app.avatarImportDialog.visible = false;
|
||||
$app.avatarImportFavoriteGroup = null;
|
||||
$app.avatarImportLocalFavoriteGroup = null;
|
||||
});
|
||||
|
||||
// #endregion
|
||||
// #region | App: friend favorite import
|
||||
|
||||
$app.data.friendImportDialog = {
|
||||
visible: false,
|
||||
loading: false,
|
||||
progress: 0,
|
||||
progressTotal: 0,
|
||||
input: '',
|
||||
userIdList: new Set(),
|
||||
errors: '',
|
||||
friendImportFavoriteGroup: null,
|
||||
importProgress: 0,
|
||||
importProgressTotal: 0
|
||||
};
|
||||
|
||||
$app.data.friendImportTable = {
|
||||
data: [],
|
||||
tableProps: {
|
||||
stripe: true,
|
||||
size: 'mini'
|
||||
},
|
||||
layout: 'table'
|
||||
};
|
||||
|
||||
$app.data.friendImportDialogVisible = false;
|
||||
$app.data.friendImportDialogInput = '';
|
||||
$app.methods.showFriendImportDialog = function () {
|
||||
this.$nextTick(() =>
|
||||
$app.adjustDialogZ(this.$refs.friendImportDialog.$el)
|
||||
);
|
||||
var D = this.friendImportDialog;
|
||||
this.resetFriendImport();
|
||||
D.visible = true;
|
||||
this.friendImportDialogVisible = true;
|
||||
};
|
||||
|
||||
$app.methods.processFriendImportList = async function () {
|
||||
var D = this.friendImportDialog;
|
||||
D.loading = true;
|
||||
var regexFriendId =
|
||||
/usr_[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}/g;
|
||||
var match = [];
|
||||
var userIdList = new Set();
|
||||
while ((match = regexFriendId.exec(D.input)) !== null) {
|
||||
userIdList.add(match[0]);
|
||||
}
|
||||
D.input = '';
|
||||
D.errors = '';
|
||||
D.progress = 0;
|
||||
D.progressTotal = userIdList.size;
|
||||
var data = Array.from(userIdList);
|
||||
for (var i = 0; i < data.length; ++i) {
|
||||
if (!D.visible) {
|
||||
this.resetFriendImport();
|
||||
}
|
||||
if (!D.loading || !D.visible) {
|
||||
break;
|
||||
}
|
||||
var userId = data[i];
|
||||
if (!D.userIdList.has(userId)) {
|
||||
try {
|
||||
var args = await userRequest.getUser({
|
||||
userId
|
||||
});
|
||||
this.friendImportTable.data.push(args.ref);
|
||||
D.userIdList.add(userId);
|
||||
} catch (err) {
|
||||
D.errors = D.errors.concat(`UserId: ${userId}\n${err}\n\n`);
|
||||
}
|
||||
}
|
||||
D.progress++;
|
||||
if (D.progress === userIdList.size) {
|
||||
D.progress = 0;
|
||||
}
|
||||
}
|
||||
D.loading = false;
|
||||
};
|
||||
|
||||
$app.methods.deleteItemFriendImport = function (ref) {
|
||||
var D = this.friendImportDialog;
|
||||
$app.removeFromArray(this.friendImportTable.data, ref);
|
||||
D.userIdList.delete(ref.id);
|
||||
};
|
||||
|
||||
$app.methods.resetFriendImport = function () {
|
||||
var D = this.friendImportDialog;
|
||||
D.input = '';
|
||||
D.errors = '';
|
||||
};
|
||||
|
||||
$app.methods.clearFriendImportTable = function () {
|
||||
var D = this.friendImportDialog;
|
||||
this.friendImportTable.data = [];
|
||||
D.userIdList = new Set();
|
||||
};
|
||||
|
||||
$app.methods.selectFriendImportGroup = function (group) {
|
||||
var D = this.friendImportDialog;
|
||||
D.friendImportFavoriteGroup = group;
|
||||
};
|
||||
|
||||
$app.methods.cancelFriendImport = function () {
|
||||
var D = this.friendImportDialog;
|
||||
D.loading = false;
|
||||
};
|
||||
|
||||
$app.methods.importFriendImportTable = async function () {
|
||||
var D = this.friendImportDialog;
|
||||
D.loading = true;
|
||||
if (!D.friendImportFavoriteGroup) {
|
||||
return;
|
||||
}
|
||||
var data = [...this.friendImportTable.data].reverse();
|
||||
D.importProgressTotal = data.length;
|
||||
try {
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
if (!D.loading || !D.visible) {
|
||||
break;
|
||||
}
|
||||
var ref = data[i];
|
||||
await this.addFavoriteUser(
|
||||
ref,
|
||||
D.friendImportFavoriteGroup,
|
||||
false
|
||||
);
|
||||
$app.removeFromArray(this.friendImportTable.data, ref);
|
||||
D.userIdList.delete(ref.id);
|
||||
D.importProgress++;
|
||||
}
|
||||
} catch (err) {
|
||||
D.errors = `Name: ${ref.displayName}\nUserId: ${ref.id}\n${err}\n\n`;
|
||||
} finally {
|
||||
D.importProgress = 0;
|
||||
D.importProgressTotal = 0;
|
||||
D.loading = false;
|
||||
}
|
||||
};
|
||||
|
||||
API.$on('LOGIN', function () {
|
||||
$app.clearFriendImportTable();
|
||||
$app.resetFriendImport();
|
||||
$app.friendImportDialog.visible = false;
|
||||
$app.friendImportFavoriteGroup = null;
|
||||
|
||||
$app.friendExportDialogVisible = false;
|
||||
$app.friendExportFavoriteGroup = null;
|
||||
});
|
||||
|
||||
// #endregion
|
||||
// #region | App: user dialog notes
|
||||
|
||||
@@ -18894,44 +18445,37 @@ console.log(`isLinux: ${LINUX}`);
|
||||
// #endregion
|
||||
// #region | App: bulk unfavorite
|
||||
|
||||
$app.methods.bulkCopyFavoriteSelection = function () {
|
||||
var idList = '';
|
||||
var type = '';
|
||||
for (var ctx of this.favoriteFriends) {
|
||||
if (ctx.$selected) {
|
||||
idList += ctx.id + '\n';
|
||||
type = 'friend';
|
||||
}
|
||||
}
|
||||
for (var ctx of this.favoriteWorlds) {
|
||||
if (ctx.$selected) {
|
||||
idList += ctx.id + '\n';
|
||||
type = 'world';
|
||||
}
|
||||
}
|
||||
for (var ctx of this.favoriteAvatars) {
|
||||
if (ctx.$selected) {
|
||||
idList += ctx.id + '\n';
|
||||
type = 'avatar';
|
||||
}
|
||||
}
|
||||
$app.methods.bulkCopyFavoriteSelection = function (type) {
|
||||
let idList = '';
|
||||
switch (type) {
|
||||
case 'friend':
|
||||
for (let ctx of this.favoriteFriends) {
|
||||
if (ctx.$selected) {
|
||||
idList += `${ctx.id}\n`;
|
||||
}
|
||||
}
|
||||
this.friendImportDialogInput = idList;
|
||||
this.showFriendImportDialog();
|
||||
this.friendImportDialog.input = idList;
|
||||
this.processFriendImportList();
|
||||
break;
|
||||
|
||||
case 'world':
|
||||
for (let ctx of this.favoriteWorlds) {
|
||||
if (ctx.$selected) {
|
||||
idList += `${ctx.id}\n`;
|
||||
}
|
||||
}
|
||||
this.worldImportDialogInput = idList;
|
||||
this.showWorldImportDialog();
|
||||
this.worldImportDialog.input = idList;
|
||||
this.processWorldImportList();
|
||||
break;
|
||||
|
||||
case 'avatar':
|
||||
for (let ctx of this.favoriteAvatars) {
|
||||
if (ctx.$selected) {
|
||||
idList += `${ctx.id}\n`;
|
||||
}
|
||||
}
|
||||
this.avatarImportDialogInput = idList;
|
||||
this.showAvatarImportDialog();
|
||||
this.avatarImportDialog.input = idList;
|
||||
this.processAvatarImportList();
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -20636,7 +20180,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
);
|
||||
};
|
||||
|
||||
$app.methods.getSmallThumbnailUrl = function (url, resolution = 64) {
|
||||
$app.methods.getSmallThumbnailUrl = function (url, resolution = 128) {
|
||||
return (
|
||||
url
|
||||
?.replace('/file/', '/image/')
|
||||
@@ -20793,6 +20337,63 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.showPreviousInstanceInfoDialog
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.friendImportDialogBind = function () {
|
||||
return {
|
||||
'friend-import-dialog-visible': this.friendImportDialogVisible,
|
||||
'friend-import-dialog-input': this.friendImportDialogInput
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.friendImportDialogEvent = function () {
|
||||
return {
|
||||
'update:friend-import-dialog-visible': (event) =>
|
||||
(this.friendImportDialogVisible = event),
|
||||
'update:friend-import-dialog-input': (event) =>
|
||||
(this.friendImportDialogInput = event)
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.worldImportDialogBind = function () {
|
||||
return {
|
||||
'world-import-dialog-visible': this.worldImportDialogVisible,
|
||||
'world-import-dialog-input': this.worldImportDialogInput,
|
||||
'get-local-world-favorite-group-length':
|
||||
this.getLocalWorldFavoriteGroupLength,
|
||||
'local-world-favorite-groups': this.localWorldFavoriteGroups
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.worldImportDialogEvent = function () {
|
||||
return {
|
||||
'update:world-import-dialog-visible': (event) =>
|
||||
(this.worldImportDialogVisible = event),
|
||||
'update:world-import-dialog-input': (event) =>
|
||||
(this.worldImportDialogInput = event),
|
||||
'add-local-world-favorite': this.addLocalWorldFavorite
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.avatarImportDialogBind = function () {
|
||||
return {
|
||||
'avatar-import-dialog-visible': this.avatarImportDialogVisible,
|
||||
'avatar-import-dialog-input': this.avatarImportDialogInput,
|
||||
'get-local-avatar-favorite-group-length':
|
||||
this.getLocalAvatarFavoriteGroupLength,
|
||||
'local-avatar-favorite-groups': this.localAvatarFavoriteGroups
|
||||
};
|
||||
};
|
||||
|
||||
$app.computed.avatarImportDialogEvent = function () {
|
||||
return {
|
||||
'update:avatar-import-dialog-visible': (event) =>
|
||||
(this.avatarImportDialogVisible = event),
|
||||
'update:avatar-import-dialog-input': (event) =>
|
||||
(this.avatarImportDialogInput = event),
|
||||
'add-local-avatar-favorite': this.addLocalAvatarFavorite
|
||||
};
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region | Electron
|
||||
|
||||
Reference in New Issue
Block a user