mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-05 22:36:05 +02:00
Local friend import/export
This commit is contained in:
@@ -162,6 +162,12 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
.map((fav) => fav.id)
|
.map((fav) => fav.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const localFriendFavoritesList = computed(() =>
|
||||||
|
Object.values(localFriendFavorites)
|
||||||
|
.flat()
|
||||||
|
.map((userId) => userId)
|
||||||
|
);
|
||||||
|
|
||||||
const groupedByGroupKeyFavoriteFriends = computed(() => {
|
const groupedByGroupKeyFavoriteFriends = computed(() => {
|
||||||
const groupedByGroupKeyFavoriteFriends = {};
|
const groupedByGroupKeyFavoriteFriends = {};
|
||||||
favoriteFriends.value.forEach((friend) => {
|
favoriteFriends.value.forEach((friend) => {
|
||||||
@@ -1765,6 +1771,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
localAvatarFavoriteGroups,
|
localAvatarFavoriteGroups,
|
||||||
favoriteDialog,
|
favoriteDialog,
|
||||||
localWorldFavoritesList,
|
localWorldFavoritesList,
|
||||||
|
localFriendFavoritesList,
|
||||||
|
|
||||||
localWorldFavoriteGroups,
|
localWorldFavoriteGroups,
|
||||||
localFriendFavorites,
|
localFriendFavorites,
|
||||||
|
|||||||
@@ -591,7 +591,8 @@
|
|||||||
localAvatarFavorites,
|
localAvatarFavorites,
|
||||||
selectedFavoriteAvatars,
|
selectedFavoriteAvatars,
|
||||||
isFavoriteLoading,
|
isFavoriteLoading,
|
||||||
localAvatarFavoriteGroups
|
localAvatarFavoriteGroups,
|
||||||
|
avatarImportDialogInput
|
||||||
} = storeToRefs(favoriteStore);
|
} = storeToRefs(favoriteStore);
|
||||||
const {
|
const {
|
||||||
showAvatarImportDialog,
|
showAvatarImportDialog,
|
||||||
@@ -1239,11 +1240,13 @@
|
|||||||
description: 'Continue? Clear Group',
|
description: 'Continue? Clear Group',
|
||||||
title: 'Confirm'
|
title: 'Confirm'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(({ ok }) => {
|
||||||
favoriteRequest.clearFavoriteGroup({
|
if (ok) {
|
||||||
type: ctx.type,
|
favoriteRequest.clearFavoriteGroup({
|
||||||
group: ctx.name
|
type: ctx.type,
|
||||||
});
|
group: ctx.name
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
@@ -1276,10 +1279,14 @@
|
|||||||
function promptLocalAvatarFavoriteGroupDelete(group) {
|
function promptLocalAvatarFavoriteGroupDelete(group) {
|
||||||
modalStore
|
modalStore
|
||||||
.confirm({
|
.confirm({
|
||||||
description: `Trash2 Group? ${group}`,
|
description: `Delete Group? ${group}`,
|
||||||
title: 'Confirm'
|
title: 'Confirm'
|
||||||
})
|
})
|
||||||
.then(() => deleteLocalAvatarFavoriteGroup(group))
|
.then(({ ok }) => {
|
||||||
|
if (ok) {
|
||||||
|
deleteLocalAvatarFavoriteGroup(group);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1400,6 +1407,55 @@
|
|||||||
refreshingLocalFavorites.value = false;
|
refreshingLocalFavorites.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleSelectAllAvatars() {
|
||||||
|
if (!activeRemoteGroup.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isAllAvatarsSelected.value) {
|
||||||
|
selectedFavoriteAvatars.value = [];
|
||||||
|
} else {
|
||||||
|
selectedFavoriteAvatars.value = currentRemoteFavorites.value.map((fav) => fav.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function copySelectedAvatars() {
|
||||||
|
if (!selectedFavoriteAvatars.value.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const idList = selectedFavoriteAvatars.value.map((id) => `${id}\n`).join('');
|
||||||
|
avatarImportDialogInput.value = idList;
|
||||||
|
showAvatarImportDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showAvatarBulkUnfavoriteSelectionConfirm() {
|
||||||
|
if (!selectedFavoriteAvatars.value.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const total = selectedFavoriteAvatars.value.length;
|
||||||
|
modalStore
|
||||||
|
.confirm({
|
||||||
|
description: `Are you sure you want to unfavorite ${total} favorites?
|
||||||
|
This action cannot be undone.`,
|
||||||
|
title: `Delete ${total} favorites?`
|
||||||
|
})
|
||||||
|
.then(({ ok }) => {
|
||||||
|
if (ok) {
|
||||||
|
bulkUnfavoriteSelectedAvatars(selectedFavoriteAvatars.value);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
function bulkUnfavoriteSelectedAvatars(ids) {
|
||||||
|
ids.forEach((id) => {
|
||||||
|
favoriteRequest.deleteFavorite({
|
||||||
|
objectId: id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
selectedFavoriteAvatars.value = [];
|
||||||
|
avatarEditMode.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
cancelLocalAvatarRefresh();
|
cancelLocalAvatarRefresh();
|
||||||
if (avatarSplitterObserver) {
|
if (avatarSplitterObserver) {
|
||||||
|
|||||||
@@ -930,7 +930,7 @@
|
|||||||
modalStore
|
modalStore
|
||||||
.confirm({
|
.confirm({
|
||||||
description: `Are you sure you want to unfavorite ${total} favorites?\n This action cannot be undone.`,
|
description: `Are you sure you want to unfavorite ${total} favorites?\n This action cannot be undone.`,
|
||||||
title: `Trash2 ${total} favorites?`
|
title: `Delete ${total} favorites?`
|
||||||
})
|
})
|
||||||
.then(({ ok }) => ok && bulkUnfavoriteSelectedFriends([...selectedFavoriteFriends.value]))
|
.then(({ ok }) => ok && bulkUnfavoriteSelectedFriends([...selectedFavoriteFriends.value]))
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
@@ -958,11 +958,13 @@
|
|||||||
description: 'Continue? Clear Group',
|
description: 'Continue? Clear Group',
|
||||||
title: 'Confirm'
|
title: 'Confirm'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(({ ok }) => {
|
||||||
favoriteRequest.clearFavoriteGroup({
|
if (ok) {
|
||||||
type: ctx.type,
|
favoriteRequest.clearFavoriteGroup({
|
||||||
group: ctx.name
|
type: ctx.type,
|
||||||
});
|
group: ctx.name
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1095,9 +1095,13 @@
|
|||||||
.confirm({
|
.confirm({
|
||||||
description: `Are you sure you want to unfavorite ${total} favorites?
|
description: `Are you sure you want to unfavorite ${total} favorites?
|
||||||
This action cannot be undone.`,
|
This action cannot be undone.`,
|
||||||
title: `Trash2 ${total} favorites?`
|
title: `Delete ${total} favorites?`
|
||||||
|
})
|
||||||
|
.then(({ ok }) => {
|
||||||
|
if (ok) {
|
||||||
|
bulkUnfavoriteSelectedWorlds([...selectedFavoriteWorlds.value]);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(() => bulkUnfavoriteSelectedWorlds([...selectedFavoriteWorlds.value]))
|
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1170,10 +1174,14 @@
|
|||||||
function promptLocalWorldFavoriteGroupDelete(group) {
|
function promptLocalWorldFavoriteGroupDelete(group) {
|
||||||
modalStore
|
modalStore
|
||||||
.confirm({
|
.confirm({
|
||||||
description: `Trash2 Group? ${group}`,
|
description: `Delete Group? ${group}`,
|
||||||
title: 'Confirm'
|
title: 'Confirm'
|
||||||
})
|
})
|
||||||
.then(() => deleteLocalWorldFavoriteGroup(group))
|
.then(({ ok }) => {
|
||||||
|
if (ok) {
|
||||||
|
deleteLocalWorldFavoriteGroup(group);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1183,11 +1191,13 @@
|
|||||||
description: 'Continue? Clear Group',
|
description: 'Continue? Clear Group',
|
||||||
title: 'Confirm'
|
title: 'Confirm'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(({ ok }) => {
|
||||||
favoriteRequest.clearFavoriteGroup({
|
if (ok) {
|
||||||
type: ctx.type,
|
favoriteRequest.clearFavoriteGroup({
|
||||||
group: ctx.name
|
type: ctx.type,
|
||||||
});
|
group: ctx.name
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectGroup>
|
<SelectGroup>
|
||||||
<SelectItem :value="FRIEND_EXPORT_ALL_VALUE">All Favorites</SelectItem>
|
<SelectItem :value="FRIEND_EXPORT_ALL_VALUE">None</SelectItem>
|
||||||
<SelectItem
|
<SelectItem
|
||||||
v-for="groupAPI in favoriteFriendGroups"
|
v-for="groupAPI in favoriteFriendGroups"
|
||||||
:key="groupAPI.name"
|
:key="groupAPI.name"
|
||||||
@@ -23,6 +23,22 @@
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
|
<Select
|
||||||
|
:model-value="friendExportLocalFavoriteGroupSelection"
|
||||||
|
@update:modelValue="handleFriendExportLocalGroupSelect"
|
||||||
|
style="margin-top: 15px">
|
||||||
|
<SelectTrigger size="sm">
|
||||||
|
<SelectValue placeholder="Select Group" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem :value="FRIEND_EXPORT_NONE_VALUE">None</SelectItem>
|
||||||
|
<SelectItem v-for="group in localFriendFavoriteGroups" :key="group" :value="group">
|
||||||
|
{{ group }} ({{ localFriendFavorites[group].length }})
|
||||||
|
</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<InputGroupTextareaField
|
<InputGroupTextareaField
|
||||||
@@ -45,7 +61,7 @@
|
|||||||
import { toast } from 'vue-sonner';
|
import { toast } from 'vue-sonner';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import { useFavoriteStore } from '../../../stores';
|
import { useFavoriteStore, useUserStore } from '../../../stores';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
@@ -58,12 +74,24 @@
|
|||||||
|
|
||||||
const emit = defineEmits(['update:friendExportDialogVisible']);
|
const emit = defineEmits(['update:friendExportDialogVisible']);
|
||||||
|
|
||||||
const { favoriteFriends, favoriteFriendGroups } = storeToRefs(useFavoriteStore());
|
const {
|
||||||
|
favoriteFriends,
|
||||||
|
favoriteFriendGroups,
|
||||||
|
localFriendFavorites,
|
||||||
|
localFriendFavoriteGroups,
|
||||||
|
localFriendFavoritesList
|
||||||
|
} = storeToRefs(useFavoriteStore());
|
||||||
|
const { cachedUsers } = storeToRefs(useUserStore());
|
||||||
|
|
||||||
const friendExportFavoriteGroup = ref(null);
|
|
||||||
const FRIEND_EXPORT_ALL_VALUE = '__all__';
|
|
||||||
const friendExportFavoriteGroupSelection = ref(FRIEND_EXPORT_ALL_VALUE);
|
|
||||||
const friendExportContent = ref('');
|
const friendExportContent = ref('');
|
||||||
|
const friendExportFavoriteGroup = ref(null);
|
||||||
|
const friendExportLocalFavoriteGroup = ref(null);
|
||||||
|
|
||||||
|
const FRIEND_EXPORT_ALL_VALUE = '__all__';
|
||||||
|
const FRIEND_EXPORT_NONE_VALUE = '__none__';
|
||||||
|
|
||||||
|
const friendExportFavoriteGroupSelection = ref(FRIEND_EXPORT_ALL_VALUE);
|
||||||
|
const friendExportLocalFavoriteGroupSelection = ref(FRIEND_EXPORT_NONE_VALUE);
|
||||||
|
|
||||||
const isDialogVisible = computed({
|
const isDialogVisible = computed({
|
||||||
get() {
|
get() {
|
||||||
@@ -99,6 +127,15 @@
|
|||||||
selectFriendExportGroup(group);
|
selectFriendExportGroup(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFriendExportLocalGroupSelect(value) {
|
||||||
|
friendExportLocalFavoriteGroupSelection.value = value;
|
||||||
|
if (value === FRIEND_EXPORT_NONE_VALUE) {
|
||||||
|
selectFriendExportLocalGroup(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
selectFriendExportLocalGroup(value);
|
||||||
|
}
|
||||||
|
|
||||||
function handleCopyFriendExportData(event) {
|
function handleCopyFriendExportData(event) {
|
||||||
if (event.target.tagName === 'TEXTAREA') {
|
if (event.target.tagName === 'TEXTAREA') {
|
||||||
event.target.select();
|
event.target.select();
|
||||||
@@ -135,21 +172,57 @@
|
|||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
const lines = ['UserID,Name'];
|
const lines = ['UserID,Name'];
|
||||||
favoriteFriendGroups.value.forEach((group) => {
|
|
||||||
if (!friendExportFavoriteGroup.value || friendExportFavoriteGroup.value === group) {
|
if (friendExportFavoriteGroup.value) {
|
||||||
favoriteFriends.value.forEach((ref) => {
|
favoriteFriendGroups.value.forEach((group) => {
|
||||||
if (group.key === ref.groupKey) {
|
if (friendExportFavoriteGroup.value === group) {
|
||||||
lines.push(`${formatter(ref.id)},${formatter(ref.name)}`);
|
favoriteFriends.value.forEach((ref) => {
|
||||||
}
|
if (group.key === ref.groupKey) {
|
||||||
});
|
lines.push(`${formatter(ref.id)},${formatter(ref.name)}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (friendExportLocalFavoriteGroup.value) {
|
||||||
|
const favoriteGroup = localFriendFavorites.value[friendExportLocalFavoriteGroup.value];
|
||||||
|
if (!favoriteGroup) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
favoriteGroup.forEach((userId) => {
|
||||||
|
const ref = cachedUsers.value.get(userId);
|
||||||
|
if (typeof ref !== 'undefined') {
|
||||||
|
lines.push(`${formatter(ref.id)},${formatter(ref.displayName)}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// export all
|
||||||
|
favoriteFriends.value.forEach((ref) => {
|
||||||
|
lines.push(`${formatter(ref.id)},${formatter(ref.name)}`);
|
||||||
|
});
|
||||||
|
for (let i = 0; i < localFriendFavoritesList.value.length; ++i) {
|
||||||
|
const userId = localFriendFavoritesList.value[i];
|
||||||
|
const ref = cachedUsers.value.get(userId);
|
||||||
|
if (typeof ref !== 'undefined') {
|
||||||
|
lines.push(`${formatter(ref.id)},${formatter(ref.displayName)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
friendExportContent.value = lines.join('\n');
|
friendExportContent.value = lines.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectFriendExportGroup(group) {
|
function selectFriendExportGroup(group) {
|
||||||
friendExportFavoriteGroup.value = group;
|
friendExportFavoriteGroup.value = group;
|
||||||
|
friendExportLocalFavoriteGroup.value = null;
|
||||||
friendExportFavoriteGroupSelection.value = group?.name ?? FRIEND_EXPORT_ALL_VALUE;
|
friendExportFavoriteGroupSelection.value = group?.name ?? FRIEND_EXPORT_ALL_VALUE;
|
||||||
|
friendExportLocalFavoriteGroupSelection.value = FRIEND_EXPORT_NONE_VALUE;
|
||||||
|
updateFriendExportDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectFriendExportLocalGroup(groupName) {
|
||||||
|
friendExportLocalFavoriteGroup.value = groupName;
|
||||||
|
friendExportFavoriteGroup.value = null;
|
||||||
|
friendExportFavoriteGroupSelection.value = FRIEND_EXPORT_ALL_VALUE;
|
||||||
|
friendExportLocalFavoriteGroupSelection.value = groupName ?? FRIEND_EXPORT_NONE_VALUE;
|
||||||
updateFriendExportDialog();
|
updateFriendExportDialog();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -25,26 +25,44 @@
|
|||||||
:rows="10"
|
:rows="10"
|
||||||
style="margin-top: 10px"
|
style="margin-top: 10px"
|
||||||
input-class="resize-none" />
|
input-class="resize-none" />
|
||||||
<div style="display: flex; align-items: center; justify-content: space-between; margin-top: 5px">
|
<div>
|
||||||
<div>
|
<div class="mb-2">
|
||||||
<Select
|
<div class="flex items-center gap-2">
|
||||||
:model-value="friendImportFavoriteGroupSelection"
|
<Select
|
||||||
@update:modelValue="handleFriendImportGroupSelect">
|
:model-value="friendImportFavoriteGroupSelection"
|
||||||
<SelectTrigger size="sm">
|
@update:modelValue="handleFriendImportGroupSelect">
|
||||||
<SelectValue :placeholder="t('dialog.friend_import.select_group_placeholder')" />
|
<SelectTrigger size="sm">
|
||||||
</SelectTrigger>
|
<SelectValue :placeholder="t('dialog.friend_import.select_group_placeholder')" />
|
||||||
<SelectContent>
|
</SelectTrigger>
|
||||||
<SelectGroup>
|
<SelectContent>
|
||||||
<SelectItem
|
<SelectGroup>
|
||||||
v-for="groupAPI in favoriteFriendGroups"
|
<SelectItem
|
||||||
:key="groupAPI.name"
|
v-for="groupAPI in favoriteFriendGroups"
|
||||||
:value="groupAPI.name"
|
:key="groupAPI.name"
|
||||||
:disabled="groupAPI.count >= groupAPI.capacity">
|
:value="groupAPI.name"
|
||||||
{{ groupAPI.displayName }} ({{ groupAPI.count }}/{{ groupAPI.capacity }})
|
:disabled="groupAPI.count >= groupAPI.capacity">
|
||||||
</SelectItem>
|
{{ groupAPI.displayName }} ({{ groupAPI.count }}/{{ groupAPI.capacity }})
|
||||||
</SelectGroup>
|
</SelectItem>
|
||||||
</SelectContent>
|
</SelectGroup>
|
||||||
</Select>
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
<Select
|
||||||
|
:model-value="friendImportLocalFavoriteGroupSelection"
|
||||||
|
@update:modelValue="handleFriendImportLocalGroupSelect"
|
||||||
|
style="margin-left: 10px">
|
||||||
|
<SelectTrigger size="sm">
|
||||||
|
<SelectValue :placeholder="t('dialog.world_import.select_local_group_placeholder')" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem v-for="group in localFriendFavoriteGroups" :key="group" :value="group">
|
||||||
|
{{ group }} ({{ localFriendFavGroupLength(group) }})
|
||||||
|
</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
<span v-if="friendImportDialog.friendImportFavoriteGroup" style="margin-left: 5px">
|
<span v-if="friendImportDialog.friendImportFavoriteGroup" style="margin-left: 5px">
|
||||||
{{ friendImportTable.data.length }} /
|
{{ friendImportTable.data.length }} /
|
||||||
{{
|
{{
|
||||||
@@ -64,7 +82,11 @@
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
:disabled="friendImportTable.data.length === 0 || !friendImportDialog.friendImportFavoriteGroup"
|
:disabled="
|
||||||
|
friendImportTable.data.length === 0 ||
|
||||||
|
(!friendImportDialog.friendImportFavoriteGroup &&
|
||||||
|
!friendImportDialog.friendImportLocalFavoriteGroup)
|
||||||
|
"
|
||||||
@click="importFriendImportTable">
|
@click="importFriendImportTable">
|
||||||
{{ t('dialog.friend_import.import') }}
|
{{ t('dialog.friend_import.import') }}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -118,10 +140,10 @@
|
|||||||
const emit = defineEmits(['update:friendImportDialogInput']);
|
const emit = defineEmits(['update:friendImportDialogInput']);
|
||||||
|
|
||||||
const { showUserDialog } = useUserStore();
|
const { showUserDialog } = useUserStore();
|
||||||
const { favoriteFriendGroups, friendImportDialogInput, friendImportDialogVisible } =
|
const { favoriteFriendGroups, friendImportDialogInput, friendImportDialogVisible, localFriendFavoriteGroups } =
|
||||||
storeToRefs(useFavoriteStore());
|
storeToRefs(useFavoriteStore());
|
||||||
const { showFullscreenImageDialog } = useGalleryStore();
|
const { showFullscreenImageDialog } = useGalleryStore();
|
||||||
const { getCachedFavoritesByObjectId } = useFavoriteStore();
|
const { getCachedFavoritesByObjectId, localFriendFavGroupLength, addLocalFriendFavorite } = useFavoriteStore();
|
||||||
|
|
||||||
const friendImportDialog = ref({
|
const friendImportDialog = ref({
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -131,11 +153,13 @@
|
|||||||
userIdList: new Set(),
|
userIdList: new Set(),
|
||||||
errors: '',
|
errors: '',
|
||||||
friendImportFavoriteGroup: null,
|
friendImportFavoriteGroup: null,
|
||||||
|
friendImportLocalFavoriteGroup: null,
|
||||||
importProgress: 0,
|
importProgress: 0,
|
||||||
importProgressTotal: 0
|
importProgressTotal: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
const friendImportFavoriteGroupSelection = ref('');
|
const friendImportFavoriteGroupSelection = ref('');
|
||||||
|
const friendImportLocalFavoriteGroupSelection = ref('');
|
||||||
|
|
||||||
const friendImportTable = ref({
|
const friendImportTable = ref({
|
||||||
data: [],
|
data: [],
|
||||||
@@ -203,6 +227,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFriendImportLocalGroupSelect(value) {
|
||||||
|
friendImportLocalFavoriteGroupSelection.value = value;
|
||||||
|
selectFriendImportLocalGroup(value || null);
|
||||||
|
}
|
||||||
|
|
||||||
function cancelFriendImport() {
|
function cancelFriendImport() {
|
||||||
friendImportDialog.value.loading = false;
|
friendImportDialog.value.loading = false;
|
||||||
}
|
}
|
||||||
@@ -215,13 +244,23 @@
|
|||||||
friendImportDialog.value.userIdList = new Set();
|
friendImportDialog.value.userIdList = new Set();
|
||||||
}
|
}
|
||||||
function selectFriendImportGroup(group) {
|
function selectFriendImportGroup(group) {
|
||||||
|
friendImportDialog.value.friendImportLocalFavoriteGroup = null;
|
||||||
friendImportDialog.value.friendImportFavoriteGroup = group;
|
friendImportDialog.value.friendImportFavoriteGroup = group;
|
||||||
friendImportFavoriteGroupSelection.value = group?.name ?? '';
|
friendImportFavoriteGroupSelection.value = group?.name ?? '';
|
||||||
|
friendImportLocalFavoriteGroupSelection.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectFriendImportLocalGroup(group) {
|
||||||
|
friendImportDialog.value.friendImportFavoriteGroup = null;
|
||||||
|
friendImportDialog.value.friendImportLocalFavoriteGroup = group;
|
||||||
|
friendImportFavoriteGroupSelection.value = '';
|
||||||
|
friendImportLocalFavoriteGroupSelection.value = group ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
async function importFriendImportTable() {
|
async function importFriendImportTable() {
|
||||||
const D = friendImportDialog.value;
|
const D = friendImportDialog.value;
|
||||||
D.loading = true;
|
D.loading = true;
|
||||||
if (!D.friendImportFavoriteGroup) {
|
if (!D.friendImportFavoriteGroup && !D.friendImportLocalFavoriteGroup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = [...friendImportTable.value.data].reverse();
|
const data = [...friendImportTable.value.data].reverse();
|
||||||
@@ -233,10 +272,14 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ref = data[i];
|
ref = data[i];
|
||||||
if (getCachedFavoritesByObjectId(ref.id)) {
|
if (D.friendImportFavoriteGroup) {
|
||||||
throw new Error('Friend is already in favorites');
|
if (getCachedFavoritesByObjectId(ref.id)) {
|
||||||
|
throw new Error('Friend is already in favorites');
|
||||||
|
}
|
||||||
|
await addFavoriteUser(ref, D.friendImportFavoriteGroup, false);
|
||||||
|
} else if (D.friendImportLocalFavoriteGroup) {
|
||||||
|
addLocalFriendFavorite(ref.id, D.friendImportLocalFavoriteGroup);
|
||||||
}
|
}
|
||||||
await addFavoriteUser(ref, D.friendImportFavoriteGroup, false);
|
|
||||||
removeFromArray(friendImportTable.value.data, ref);
|
removeFromArray(friendImportTable.value.data, ref);
|
||||||
D.userIdList.delete(ref.id);
|
D.userIdList.delete(ref.id);
|
||||||
D.importProgress++;
|
D.importProgress++;
|
||||||
|
|||||||
Reference in New Issue
Block a user