summaryrefslogtreecommitdiff
path: root/packages/client/src/scripts/select-file.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/client/src/scripts/select-file.ts')
-rw-r--r--packages/client/src/scripts/select-file.ts23
1 files changed, 15 insertions, 8 deletions
diff --git a/packages/client/src/scripts/select-file.ts b/packages/client/src/scripts/select-file.ts
index 6bb3f8bf8a..23df4edf54 100644
--- a/packages/client/src/scripts/select-file.ts
+++ b/packages/client/src/scripts/select-file.ts
@@ -1,3 +1,4 @@
+import { ref } from 'vue';
import * as os from '@/os';
import { stream } from '@/stream';
import { i18n } from '@/i18n';
@@ -6,12 +7,14 @@ import { DriveFile } from 'misskey-js/built/entities';
function select(src: any, label: string | null, multiple: boolean): Promise<DriveFile | DriveFile[]> {
return new Promise((res, rej) => {
+ const keepOriginal = ref(defaultStore.state.keepOriginalUploading);
+
const chooseFileFromPc = () => {
const input = document.createElement('input');
input.type = 'file';
input.multiple = multiple;
input.onchange = () => {
- const promises = Array.from(input.files).map(file => os.upload(file, defaultStore.state.uploadFolder));
+ const promises = Array.from(input.files).map(file => os.upload(file, defaultStore.state.uploadFolder, undefined, keepOriginal.value));
Promise.all(promises).then(driveFiles => {
res(multiple ? driveFiles : driveFiles[0]);
@@ -41,9 +44,9 @@ function select(src: any, label: string | null, multiple: boolean): Promise<Driv
const chooseFileFromUrl = () => {
os.inputText({
- title: i18n.locale.uploadFromUrl,
+ title: i18n.ts.uploadFromUrl,
type: 'url',
- placeholder: i18n.locale.uploadFromUrlDescription
+ placeholder: i18n.ts.uploadFromUrlDescription
}).then(({ canceled, result: url }) => {
if (canceled) return;
@@ -64,8 +67,8 @@ function select(src: any, label: string | null, multiple: boolean): Promise<Driv
});
os.alert({
- title: i18n.locale.uploadFromUrlRequested,
- text: i18n.locale.uploadFromUrlMayTakeTime
+ title: i18n.ts.uploadFromUrlRequested,
+ text: i18n.ts.uploadFromUrlMayTakeTime
});
});
};
@@ -74,15 +77,19 @@ function select(src: any, label: string | null, multiple: boolean): Promise<Driv
text: label,
type: 'label'
} : undefined, {
- text: i18n.locale.upload,
+ type: 'switch',
+ text: i18n.ts.keepOriginalUploading,
+ ref: keepOriginal
+ }, {
+ text: i18n.ts.upload,
icon: 'fas fa-upload',
action: chooseFileFromPc
}, {
- text: i18n.locale.fromDrive,
+ text: i18n.ts.fromDrive,
icon: 'fas fa-cloud',
action: chooseFileFromDrive
}, {
- text: i18n.locale.fromUrl,
+ text: i18n.ts.fromUrl,
icon: 'fas fa-link',
action: chooseFileFromUrl
}], src);