restore import/export settings

This commit is contained in:
Hazelnoot 2025-03-26 20:27:27 -04:00
parent f840b75fe2
commit 0c34bf26dc

View file

@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkFeatureBanner> </MkFeatureBanner>
<div class="_gaps_s"> <div class="_gaps_s">
<SearchMarker :keywords="['notes']"> <SearchMarker :keywords="['notes', 'export']">
<MkFolder> <MkFolder>
<template #icon><i class="ti ti-pencil"></i></template> <template #icon><i class="ti ti-pencil"></i></template>
<template #label><SearchLabel>{{ i18n.ts._exportOrImport.allNotes }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts._exportOrImport.allNotes }}</SearchLabel></template>
@ -23,6 +23,22 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkFolder> </MkFolder>
</SearchMarker> </SearchMarker>
<SearchMarker :keywords="['notes', 'import']">
<MkFolder v-if="$i && $i.policies.canImportNotes">
<template #label><SearchLabel>{{ i18n.ts.import }}</SearchLabel></template>
<template #icon><i class="ph-upload ph-bold ph-lg"></i></template>
<MkRadios v-model="noteType" style="padding-bottom: 8px;" small>
<template #label>Origin</template>
<option value="Misskey">Misskey/Firefish</option>
<option value="Mastodon">Mastodon/Pleroma/Akkoma</option>
<option value="Twitter">Twitter</option>
<option value="Instagram">Instagram</option>
<option value="Facebook">Facebook</option>
</MkRadios>
<MkButton primary :class="$style.button" inline @click="importNotes($event)"><i class="ph-upload ph-bold ph-lg"></i> {{ i18n.ts.import }}</MkButton>
</MkFolder>
</SearchMarker>
<SearchMarker :keywords="['favorite', 'notes']"> <SearchMarker :keywords="['favorite', 'notes']">
<MkFolder> <MkFolder>
<template #icon><i class="ti ti-star"></i></template> <template #icon><i class="ti ti-star"></i></template>
@ -162,6 +178,7 @@ import { ref, computed } from 'vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
import MkRadios from '@/components/MkRadios.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/utility/misskey-api.js'; import { misskeyApi } from '@/utility/misskey-api.js';
import { selectFile } from '@/utility/select-file.js'; import { selectFile } from '@/utility/select-file.js';
@ -173,6 +190,7 @@ import { prefer } from '@/preferences.js';
const excludeMutingUsers = ref(false); const excludeMutingUsers = ref(false);
const excludeInactiveUsers = ref(false); const excludeInactiveUsers = ref(false);
const noteType = ref(null);
const withReplies = ref(prefer.s.defaultFollowWithReplies); const withReplies = ref(prefer.s.defaultFollowWithReplies);
const onExportSuccess = () => { const onExportSuccess = () => {
@ -240,6 +258,14 @@ const importFollowing = async (ev) => {
}).then(onImportSuccess).catch(onError); }).then(onImportSuccess).catch(onError);
}; };
const importNotes = async (ev) => {
const file = await selectFile(ev.currentTarget ?? ev.target);
misskeyApi('i/import-notes', {
fileId: file.id,
type: noteType.value,
}).then(onImportSuccess).catch(onError);
};
const importUserLists = async (ev) => { const importUserLists = async (ev) => {
const file = await selectFile(ev.currentTarget ?? ev.target); const file = await selectFile(ev.currentTarget ?? ev.target);
misskeyApi('i/import-user-lists', { fileId: file.id }).then(onImportSuccess).catch(onError); misskeyApi('i/import-user-lists', { fileId: file.id }).then(onImportSuccess).catch(onError);