2023-07-27 05:31:52 +00:00
|
|
|
|
/*
|
2024-02-13 15:59:27 +00:00
|
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 05:31:52 +00:00
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2021-02-27 04:08:34 +00:00
|
|
|
|
// TODO: なんでもかんでもos.tsに突っ込むのやめたいのでよしなに分割する
|
|
|
|
|
|
2024-07-12 07:25:44 +00:00
|
|
|
|
import { Component, markRaw, Ref, ref, defineAsyncComponent, nextTick } from 'vue';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
import { EventEmitter } from 'eventemitter3';
|
2021-05-27 08:15:08 +00:00
|
|
|
|
import * as Misskey from 'misskey-js';
|
2024-02-28 09:26:38 +00:00
|
|
|
|
import type { ComponentProps as CP } from 'vue-component-type-helpers';
|
|
|
|
|
import type { Form, GetFormResultType } from '@/scripts/form.js';
|
2024-10-13 11:21:25 +00:00
|
|
|
|
import type { MenuItem } from '@/types/menu.js';
|
2024-01-04 09:32:46 +00:00
|
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2024-07-30 05:45:53 +00:00
|
|
|
|
import { defaultStore } from '@/store.js';
|
2023-09-19 07:37:43 +00:00
|
|
|
|
import { i18n } from '@/i18n.js';
|
2022-08-30 15:24:33 +00:00
|
|
|
|
import MkPostFormDialog from '@/components/MkPostFormDialog.vue';
|
|
|
|
|
import MkWaitingDialog from '@/components/MkWaitingDialog.vue';
|
2023-01-21 06:30:29 +00:00
|
|
|
|
import MkPageWindow from '@/components/MkPageWindow.vue';
|
2023-01-17 08:36:18 +00:00
|
|
|
|
import MkToast from '@/components/MkToast.vue';
|
|
|
|
|
import MkDialog from '@/components/MkDialog.vue';
|
2023-09-22 05:12:33 +00:00
|
|
|
|
import MkPasswordDialog from '@/components/MkPasswordDialog.vue';
|
2023-01-17 08:36:18 +00:00
|
|
|
|
import MkEmojiPickerDialog from '@/components/MkEmojiPickerDialog.vue';
|
|
|
|
|
import MkPopupMenu from '@/components/MkPopupMenu.vue';
|
|
|
|
|
import MkContextMenu from '@/components/MkContextMenu.vue';
|
2024-07-17 12:52:05 +00:00
|
|
|
|
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
|
2024-07-14 06:27:52 +00:00
|
|
|
|
import { pleaseLogin } from '@/scripts/please-login.js';
|
2023-09-19 07:37:43 +00:00
|
|
|
|
import { showMovedDialog } from '@/scripts/show-moved-dialog.js';
|
2024-07-12 07:25:44 +00:00
|
|
|
|
import { getHTMLElementOrNull } from '@/scripts/get-dom-node-or-null.js';
|
2024-07-12 07:39:09 +00:00
|
|
|
|
import { focusParent } from '@/scripts/focus.js';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
2023-01-21 06:30:29 +00:00
|
|
|
|
export const openingWindowsCount = ref(0);
|
|
|
|
|
|
2024-02-28 09:26:38 +00:00
|
|
|
|
export const apiWithDialog = (<E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req']>(
|
|
|
|
|
endpoint: E,
|
|
|
|
|
data: P = {} as any,
|
2020-10-18 01:11:34 +00:00
|
|
|
|
token?: string | null | undefined,
|
2024-10-13 11:21:25 +00:00
|
|
|
|
customErrors?: Record<string, { title?: string; text: string; }>,
|
2021-05-27 08:15:08 +00:00
|
|
|
|
) => {
|
2024-01-04 09:32:46 +00:00
|
|
|
|
const promise = misskeyApi(endpoint, data, token);
|
2023-02-12 01:21:17 +00:00
|
|
|
|
promiseDialog(promise, null, async (err) => {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
let title: string | undefined;
|
|
|
|
|
let text = err.message + '\n' + err.id;
|
2023-02-12 01:21:17 +00:00
|
|
|
|
if (err.code === 'INTERNAL_ERROR') {
|
|
|
|
|
title = i18n.ts.internalServerError;
|
|
|
|
|
text = i18n.ts.internalServerErrorDescription;
|
|
|
|
|
const date = new Date().toISOString();
|
|
|
|
|
const { result } = await actions({
|
|
|
|
|
type: 'error',
|
|
|
|
|
title,
|
|
|
|
|
text,
|
|
|
|
|
actions: [{
|
|
|
|
|
value: 'ok',
|
|
|
|
|
text: i18n.ts.gotIt,
|
|
|
|
|
primary: true,
|
|
|
|
|
}, {
|
|
|
|
|
value: 'copy',
|
|
|
|
|
text: i18n.ts.copyErrorInfo,
|
|
|
|
|
}],
|
|
|
|
|
});
|
|
|
|
|
if (result === 'copy') {
|
|
|
|
|
copyToClipboard(`Endpoint: ${endpoint}\nInfo: ${JSON.stringify(err.info)}\nDate: ${date}`);
|
|
|
|
|
success();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
} else if (err.code === 'RATE_LIMIT_EXCEEDED') {
|
2023-01-15 07:13:57 +00:00
|
|
|
|
title = i18n.ts.cannotPerformTemporary;
|
|
|
|
|
text = i18n.ts.cannotPerformTemporaryDescription;
|
2023-04-21 00:17:44 +00:00
|
|
|
|
} else if (err.code === 'INVALID_PARAM') {
|
|
|
|
|
title = i18n.ts.invalidParamError;
|
|
|
|
|
text = i18n.ts.invalidParamErrorDescription;
|
|
|
|
|
} else if (err.code === 'ROLE_PERMISSION_DENIED') {
|
|
|
|
|
title = i18n.ts.permissionDeniedError;
|
|
|
|
|
text = i18n.ts.permissionDeniedErrorDescription;
|
2023-01-15 07:13:57 +00:00
|
|
|
|
} else if (err.code.startsWith('TOO_MANY')) {
|
2023-01-14 08:46:45 +00:00
|
|
|
|
title = i18n.ts.youCannotCreateAnymore;
|
|
|
|
|
text = `${i18n.ts.error}: ${err.id}`;
|
2023-02-09 09:07:51 +00:00
|
|
|
|
} else if (err.message.startsWith('Unexpected token')) {
|
|
|
|
|
title = i18n.ts.gotInvalidResponseError;
|
|
|
|
|
text = i18n.ts.gotInvalidResponseErrorDescription;
|
2024-10-13 11:21:25 +00:00
|
|
|
|
} else if (customErrors && customErrors[err.id] != null) {
|
|
|
|
|
title = customErrors[err.id].title;
|
|
|
|
|
text = customErrors[err.id].text;
|
2023-01-14 08:46:45 +00:00
|
|
|
|
}
|
2021-11-18 14:36:04 +00:00
|
|
|
|
alert({
|
2020-10-18 01:21:02 +00:00
|
|
|
|
type: 'error',
|
2023-01-14 08:46:45 +00:00
|
|
|
|
title,
|
|
|
|
|
text,
|
2020-10-18 01:21:02 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
2020-10-18 01:11:34 +00:00
|
|
|
|
|
|
|
|
|
return promise;
|
2024-10-13 11:21:25 +00:00
|
|
|
|
});
|
2020-10-18 01:11:34 +00:00
|
|
|
|
|
|
|
|
|
export function promiseDialog<T extends Promise<any>>(
|
|
|
|
|
promise: T,
|
2021-01-03 14:58:24 +00:00
|
|
|
|
onSuccess?: ((res: any) => void) | null,
|
2024-02-28 09:26:38 +00:00
|
|
|
|
onFailure?: ((err: Misskey.api.APIError) => void) | null,
|
2020-10-18 01:11:34 +00:00
|
|
|
|
text?: string,
|
|
|
|
|
): T {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
const showing = ref(true);
|
2020-10-18 01:11:34 +00:00
|
|
|
|
const success = ref(false);
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
|
|
promise.then(res => {
|
|
|
|
|
if (onSuccess) {
|
|
|
|
|
showing.value = false;
|
|
|
|
|
onSuccess(res);
|
|
|
|
|
} else {
|
2020-10-18 01:11:34 +00:00
|
|
|
|
success.value = true;
|
2022-01-16 01:14:14 +00:00
|
|
|
|
window.setTimeout(() => {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
showing.value = false;
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
2022-05-26 13:53:09 +00:00
|
|
|
|
}).catch(err => {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
showing.value = false;
|
|
|
|
|
if (onFailure) {
|
2022-05-26 13:53:09 +00:00
|
|
|
|
onFailure(err);
|
2020-10-17 11:12:00 +00:00
|
|
|
|
} else {
|
2021-11-18 14:36:04 +00:00
|
|
|
|
alert({
|
2020-10-17 11:12:00 +00:00
|
|
|
|
type: 'error',
|
2022-05-26 13:53:09 +00:00
|
|
|
|
text: err,
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-10-19 10:29:04 +00:00
|
|
|
|
// NOTE: dynamic importすると挙動がおかしくなる(showingの変更が伝播しない)
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkWaitingDialog, {
|
2020-10-18 01:11:34 +00:00
|
|
|
|
success: success,
|
|
|
|
|
showing: showing,
|
|
|
|
|
text: text,
|
2024-07-04 04:14:49 +00:00
|
|
|
|
}, {
|
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-01 04:38:48 +00:00
|
|
|
|
let popupIdCount = 0;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
export const popups = ref([]) as Ref<{
|
2024-02-05 06:02:30 +00:00
|
|
|
|
id: number;
|
|
|
|
|
component: Component;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
props: Record<string, any>;
|
2024-02-05 06:02:30 +00:00
|
|
|
|
events: Record<string, any>;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}[]>;
|
|
|
|
|
|
2021-12-18 03:12:47 +00:00
|
|
|
|
const zIndexes = {
|
2023-01-02 04:23:12 +00:00
|
|
|
|
veryLow: 500000,
|
2021-12-18 03:12:47 +00:00
|
|
|
|
low: 1000000,
|
|
|
|
|
middle: 2000000,
|
|
|
|
|
high: 3000000,
|
|
|
|
|
};
|
2023-01-02 04:23:12 +00:00
|
|
|
|
export function claimZIndex(priority: keyof typeof zIndexes = 'low'): number {
|
2021-12-18 03:12:47 +00:00
|
|
|
|
zIndexes[priority] += 100;
|
|
|
|
|
return zIndexes[priority];
|
2021-12-10 09:20:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-05 06:02:30 +00:00
|
|
|
|
// InstanceType<typeof Component>['$emit'] だとインターセクション型が返ってきて
|
|
|
|
|
// 使い物にならないので、代わりに ['$props'] から色々省くことで emit の型を生成する
|
|
|
|
|
// FIXME: 何故か *.ts ファイルからだと型がうまく取れない?ことがあるのをなんとかしたい
|
|
|
|
|
type ComponentEmit<T> = T extends new () => { $props: infer Props }
|
2024-02-28 09:26:38 +00:00
|
|
|
|
? [keyof Pick<T, Extract<keyof T, `on${string}`>>] extends [never]
|
|
|
|
|
? Record<string, unknown> // *.ts ファイルから型がうまく取れないとき用(これがないと {} になって型エラーがうるさい)
|
|
|
|
|
: EmitsExtractor<Props>
|
|
|
|
|
: T extends (...args: any) => any
|
|
|
|
|
? ReturnType<T> extends { [x: string]: any; __ctx?: { [x: string]: any; props: infer Props } }
|
|
|
|
|
? [keyof Pick<T, Extract<keyof T, `on${string}`>>] extends [never]
|
|
|
|
|
? Record<string, unknown>
|
|
|
|
|
: EmitsExtractor<Props>
|
|
|
|
|
: never
|
|
|
|
|
: never;
|
|
|
|
|
|
|
|
|
|
// props に ref を許可するようにする
|
|
|
|
|
type ComponentProps<T extends Component> = { [K in keyof CP<T>]: CP<T>[K] | Ref<CP<T>[K]> };
|
2024-02-05 06:02:30 +00:00
|
|
|
|
|
|
|
|
|
type EmitsExtractor<T> = {
|
|
|
|
|
[K in keyof T as K extends `onVnode${string}` ? never : K extends `on${infer E}` ? Uncapitalize<E> : K extends string ? never : K]: T[K];
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-04 04:14:49 +00:00
|
|
|
|
export function popup<T extends Component>(
|
2024-02-28 09:26:38 +00:00
|
|
|
|
component: T,
|
|
|
|
|
props: ComponentProps<T>,
|
|
|
|
|
events: ComponentEmit<T> = {} as ComponentEmit<T>,
|
2024-07-04 04:14:49 +00:00
|
|
|
|
): { dispose: () => void } {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
markRaw(component);
|
|
|
|
|
|
2020-11-01 04:38:48 +00:00
|
|
|
|
const id = ++popupIdCount;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
const dispose = () => {
|
|
|
|
|
// このsetTimeoutが無いと挙動がおかしくなる(autocompleteが閉じなくなる)。Vueのバグ?
|
2022-01-16 01:14:14 +00:00
|
|
|
|
window.setTimeout(() => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
popups.value = popups.value.filter(p => p.id !== id);
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}, 0);
|
|
|
|
|
};
|
|
|
|
|
const state = {
|
|
|
|
|
component,
|
|
|
|
|
props,
|
2024-07-04 04:14:49 +00:00
|
|
|
|
events,
|
2020-10-17 11:12:00 +00:00
|
|
|
|
id,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
popups.value.push(state);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
dispose,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 01:06:19 +00:00
|
|
|
|
export function pageWindow(path: string) {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkPageWindow, {
|
2020-11-03 01:06:19 +00:00
|
|
|
|
initialPath: path,
|
2024-07-04 04:14:49 +00:00
|
|
|
|
}, {
|
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-28 11:07:37 +00:00
|
|
|
|
export function toast(message: string) {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkToast, {
|
2022-06-11 06:45:44 +00:00
|
|
|
|
message,
|
2024-07-04 04:14:49 +00:00
|
|
|
|
}, {
|
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2021-11-28 11:07:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-18 09:45:58 +00:00
|
|
|
|
export function alert(props: {
|
|
|
|
|
type?: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question';
|
2024-02-28 09:26:38 +00:00
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
2021-11-18 09:45:58 +00:00
|
|
|
|
}): Promise<void> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkDialog, props, {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
done: () => {
|
2021-11-18 09:45:58 +00:00
|
|
|
|
resolve();
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2021-11-18 09:45:58 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function confirm(props: {
|
|
|
|
|
type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question';
|
2024-02-28 09:26:38 +00:00
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
2023-02-10 01:45:32 +00:00
|
|
|
|
okText?: string;
|
|
|
|
|
cancelText?: string;
|
2021-11-18 09:45:58 +00:00
|
|
|
|
}): Promise<{ canceled: boolean }> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkDialog, {
|
2021-11-18 09:45:58 +00:00
|
|
|
|
...props,
|
|
|
|
|
showCancelButton: true,
|
|
|
|
|
}, {
|
|
|
|
|
done: result => {
|
|
|
|
|
resolve(result ? result : { canceled: true });
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2021-11-18 09:45:58 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-11 04:54:27 +00:00
|
|
|
|
// TODO: const T extends ... にしたい
|
|
|
|
|
// https://zenn.dev/general_link/articles/813e47b7a0eef7#const-type-parameters
|
|
|
|
|
export function actions<T extends {
|
|
|
|
|
value: string;
|
|
|
|
|
text: string;
|
|
|
|
|
primary?: boolean,
|
2023-04-05 05:30:03 +00:00
|
|
|
|
danger?: boolean,
|
2023-02-11 04:54:27 +00:00
|
|
|
|
}[]>(props: {
|
|
|
|
|
type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question';
|
2024-02-28 09:26:38 +00:00
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
2023-02-11 04:54:27 +00:00
|
|
|
|
actions: T;
|
2024-02-28 09:26:38 +00:00
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
2023-02-11 04:54:27 +00:00
|
|
|
|
canceled: false; result: T[number]['value'];
|
|
|
|
|
}> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkDialog, {
|
2023-02-11 04:54:27 +00:00
|
|
|
|
...props,
|
|
|
|
|
actions: props.actions.map(a => ({
|
|
|
|
|
text: a.text,
|
|
|
|
|
primary: a.primary,
|
2023-04-05 05:30:03 +00:00
|
|
|
|
danger: a.danger,
|
2023-02-11 04:54:27 +00:00
|
|
|
|
callback: () => {
|
|
|
|
|
resolve({ canceled: false, result: a.value });
|
|
|
|
|
},
|
|
|
|
|
})),
|
|
|
|
|
}, {
|
|
|
|
|
done: result => {
|
|
|
|
|
resolve(result ? result : { canceled: true });
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2023-02-11 04:54:27 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 09:26:38 +00:00
|
|
|
|
// default が指定されていたら result は null になり得ないことを保証する overload function
|
2021-11-18 09:45:58 +00:00
|
|
|
|
export function inputText(props: {
|
|
|
|
|
type?: 'text' | 'email' | 'password' | 'url';
|
2024-02-28 09:26:38 +00:00
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
2021-11-18 09:45:58 +00:00
|
|
|
|
placeholder?: string | null;
|
2023-02-20 07:40:24 +00:00
|
|
|
|
autocomplete?: string;
|
2024-02-28 09:26:38 +00:00
|
|
|
|
default: string;
|
2023-02-20 07:40:24 +00:00
|
|
|
|
minLength?: number;
|
|
|
|
|
maxLength?: number;
|
2024-02-28 09:26:38 +00:00
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
2021-11-18 09:45:58 +00:00
|
|
|
|
canceled: false; result: string;
|
2024-02-28 09:26:38 +00:00
|
|
|
|
}>;
|
|
|
|
|
export function inputText(props: {
|
|
|
|
|
type?: 'text' | 'email' | 'password' | 'url';
|
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
|
|
|
|
placeholder?: string | null;
|
|
|
|
|
autocomplete?: string;
|
|
|
|
|
default?: string | null;
|
|
|
|
|
minLength?: number;
|
|
|
|
|
maxLength?: number;
|
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
|
|
|
|
canceled: false; result: string | null;
|
|
|
|
|
}>;
|
|
|
|
|
export function inputText(props: {
|
|
|
|
|
type?: 'text' | 'email' | 'password' | 'url';
|
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
|
|
|
|
placeholder?: string | null;
|
|
|
|
|
autocomplete?: string;
|
|
|
|
|
default?: string | null;
|
|
|
|
|
minLength?: number;
|
|
|
|
|
maxLength?: number;
|
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
|
|
|
|
canceled: false; result: string | null;
|
2021-11-18 09:45:58 +00:00
|
|
|
|
}> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkDialog, {
|
2021-11-18 09:45:58 +00:00
|
|
|
|
title: props.title,
|
|
|
|
|
text: props.text,
|
|
|
|
|
input: {
|
|
|
|
|
type: props.type,
|
|
|
|
|
placeholder: props.placeholder,
|
2023-02-20 07:40:24 +00:00
|
|
|
|
autocomplete: props.autocomplete,
|
2024-02-28 09:26:38 +00:00
|
|
|
|
default: props.default ?? null,
|
2023-02-20 07:40:24 +00:00
|
|
|
|
minLength: props.minLength,
|
|
|
|
|
maxLength: props.maxLength,
|
2022-06-11 06:45:44 +00:00
|
|
|
|
},
|
2021-11-18 09:45:58 +00:00
|
|
|
|
}, {
|
|
|
|
|
done: result => {
|
|
|
|
|
resolve(result ? result : { canceled: true });
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2021-11-18 09:45:58 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 09:26:38 +00:00
|
|
|
|
// default が指定されていたら result は null になり得ないことを保証する overload function
|
2021-11-18 09:45:58 +00:00
|
|
|
|
export function inputNumber(props: {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
2021-11-18 09:45:58 +00:00
|
|
|
|
placeholder?: string | null;
|
2023-02-20 07:40:24 +00:00
|
|
|
|
autocomplete?: string;
|
2024-02-28 09:26:38 +00:00
|
|
|
|
default: number;
|
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
2021-11-18 09:45:58 +00:00
|
|
|
|
canceled: false; result: number;
|
2024-02-28 09:26:38 +00:00
|
|
|
|
}>;
|
|
|
|
|
export function inputNumber(props: {
|
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
|
|
|
|
placeholder?: string | null;
|
|
|
|
|
autocomplete?: string;
|
|
|
|
|
default?: number | null;
|
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
|
|
|
|
canceled: false; result: number | null;
|
|
|
|
|
}>;
|
|
|
|
|
export function inputNumber(props: {
|
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
|
|
|
|
placeholder?: string | null;
|
|
|
|
|
autocomplete?: string;
|
|
|
|
|
default?: number | null;
|
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
|
|
|
|
canceled: false; result: number | null;
|
2021-11-18 09:45:58 +00:00
|
|
|
|
}> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkDialog, {
|
2021-11-18 09:45:58 +00:00
|
|
|
|
title: props.title,
|
|
|
|
|
text: props.text,
|
|
|
|
|
input: {
|
|
|
|
|
type: 'number',
|
|
|
|
|
placeholder: props.placeholder,
|
2023-02-20 07:40:24 +00:00
|
|
|
|
autocomplete: props.autocomplete,
|
2024-02-28 09:26:38 +00:00
|
|
|
|
default: props.default ?? null,
|
2022-06-11 06:45:44 +00:00
|
|
|
|
},
|
2021-11-18 09:45:58 +00:00
|
|
|
|
}, {
|
|
|
|
|
done: result => {
|
|
|
|
|
resolve(result ? result : { canceled: true });
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2021-11-18 09:45:58 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function inputDate(props: {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
2021-11-18 09:45:58 +00:00
|
|
|
|
placeholder?: string | null;
|
2024-02-28 09:26:38 +00:00
|
|
|
|
default?: string | null;
|
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
2021-11-18 09:45:58 +00:00
|
|
|
|
canceled: false; result: Date;
|
|
|
|
|
}> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkDialog, {
|
2021-11-18 09:45:58 +00:00
|
|
|
|
title: props.title,
|
|
|
|
|
text: props.text,
|
|
|
|
|
input: {
|
|
|
|
|
type: 'date',
|
|
|
|
|
placeholder: props.placeholder,
|
2024-02-28 09:26:38 +00:00
|
|
|
|
default: props.default ?? null,
|
2022-06-11 06:45:44 +00:00
|
|
|
|
},
|
2021-11-18 09:45:58 +00:00
|
|
|
|
}, {
|
|
|
|
|
done: result => {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
resolve(result ? { result: new Date(result.result), canceled: false } : { result: undefined, canceled: true });
|
2021-11-18 09:45:58 +00:00
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2021-11-18 09:45:58 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 09:26:38 +00:00
|
|
|
|
export function authenticateDialog(): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
2023-09-22 05:12:33 +00:00
|
|
|
|
canceled: false; result: { password: string; token: string | null; };
|
|
|
|
|
}> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkPasswordDialog, {}, {
|
2023-09-22 05:12:33 +00:00
|
|
|
|
done: result => {
|
|
|
|
|
resolve(result ? { canceled: false, result } : { canceled: true, result: undefined });
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2023-09-22 05:12:33 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-30 04:11:06 +00:00
|
|
|
|
type SelectItem<C> = {
|
|
|
|
|
value: C;
|
|
|
|
|
text: string;
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-28 09:26:38 +00:00
|
|
|
|
// default が指定されていたら result は null になり得ないことを保証する overload function
|
2022-06-10 05:36:55 +00:00
|
|
|
|
export function select<C = any>(props: {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
|
|
|
|
default: string;
|
2024-07-30 04:11:06 +00:00
|
|
|
|
items: (SelectItem<C> | {
|
|
|
|
|
sectionTitle: string;
|
|
|
|
|
items: SelectItem<C>[];
|
|
|
|
|
} | undefined)[];
|
2024-02-28 09:26:38 +00:00
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
|
|
|
|
canceled: false; result: C;
|
|
|
|
|
}>;
|
|
|
|
|
export function select<C = any>(props: {
|
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
2021-11-18 09:45:58 +00:00
|
|
|
|
default?: string | null;
|
2024-07-30 04:11:06 +00:00
|
|
|
|
items: (SelectItem<C> | {
|
|
|
|
|
sectionTitle: string;
|
|
|
|
|
items: SelectItem<C>[];
|
|
|
|
|
} | undefined)[];
|
2024-02-28 09:26:38 +00:00
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
2022-03-20 18:11:14 +00:00
|
|
|
|
} | {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
canceled: false; result: C | null;
|
|
|
|
|
}>;
|
|
|
|
|
export function select<C = any>(props: {
|
|
|
|
|
title?: string;
|
|
|
|
|
text?: string;
|
|
|
|
|
default?: string | null;
|
2024-07-30 04:11:06 +00:00
|
|
|
|
items: (SelectItem<C> | {
|
|
|
|
|
sectionTitle: string;
|
|
|
|
|
items: SelectItem<C>[];
|
|
|
|
|
} | undefined)[];
|
2024-02-28 09:26:38 +00:00
|
|
|
|
}): Promise<{
|
|
|
|
|
canceled: true; result: undefined;
|
|
|
|
|
} | {
|
|
|
|
|
canceled: false; result: C | null;
|
2021-11-18 09:45:58 +00:00
|
|
|
|
}> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkDialog, {
|
2021-11-18 09:45:58 +00:00
|
|
|
|
title: props.title,
|
|
|
|
|
text: props.text,
|
|
|
|
|
select: {
|
2024-07-30 04:11:06 +00:00
|
|
|
|
items: props.items.filter(x => x !== undefined),
|
2024-02-28 09:26:38 +00:00
|
|
|
|
default: props.default ?? null,
|
2022-06-11 06:45:44 +00:00
|
|
|
|
},
|
2021-11-18 09:45:58 +00:00
|
|
|
|
}, {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
done: result => {
|
|
|
|
|
resolve(result ? result : { canceled: true });
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 06:05:05 +00:00
|
|
|
|
export function success(): Promise<void> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
const showing = ref(true);
|
2022-01-16 01:14:14 +00:00
|
|
|
|
window.setTimeout(() => {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
showing.value = false;
|
|
|
|
|
}, 1000);
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkWaitingDialog, {
|
2020-10-18 01:11:34 +00:00
|
|
|
|
success: true,
|
2022-06-11 06:45:44 +00:00
|
|
|
|
showing: showing,
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}, {
|
|
|
|
|
done: () => resolve(),
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 06:05:05 +00:00
|
|
|
|
export function waiting(): Promise<void> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
const showing = ref(true);
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkWaitingDialog, {
|
2020-10-18 01:11:34 +00:00
|
|
|
|
success: false,
|
2022-06-11 06:45:44 +00:00
|
|
|
|
showing: showing,
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}, {
|
|
|
|
|
done: () => resolve(),
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 11:54:53 +00:00
|
|
|
|
export function form<F extends Form>(title: string, f: F): Promise<{ canceled: true, result?: undefined } | { canceled?: false, result: GetFormResultType<F> }> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkFormDialog.vue')), { title, form: f }, {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
done: result => {
|
|
|
|
|
resolve(result);
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-30 11:54:30 +00:00
|
|
|
|
export async function selectUser(opts: { includeSelf?: boolean; localOnly?: boolean; } = {}): Promise<Misskey.entities.UserDetailed> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkUserSelectDialog.vue')), {
|
2023-01-15 20:29:44 +00:00
|
|
|
|
includeSelf: opts.includeSelf,
|
2024-01-30 11:54:30 +00:00
|
|
|
|
localOnly: opts.localOnly,
|
2023-01-15 20:29:44 +00:00
|
|
|
|
}, {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
ok: user => {
|
|
|
|
|
resolve(user);
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-04 04:33:38 +00:00
|
|
|
|
export async function selectDriveFile(multiple: boolean): Promise<Misskey.entities.DriveFile[]> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkDriveSelectDialog.vue')), {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
type: 'file',
|
2022-06-11 06:45:44 +00:00
|
|
|
|
multiple,
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}, {
|
|
|
|
|
done: files => {
|
|
|
|
|
if (files) {
|
2023-05-07 23:52:01 +00:00
|
|
|
|
resolve(files);
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 09:26:38 +00:00
|
|
|
|
export async function selectDriveFolder(multiple: boolean): Promise<Misskey.entities.DriveFolder[]> {
|
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkDriveSelectDialog.vue')), {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
type: 'folder',
|
2022-06-11 06:45:44 +00:00
|
|
|
|
multiple,
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}, {
|
|
|
|
|
done: folders => {
|
|
|
|
|
if (folders) {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
resolve(folders);
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 09:26:38 +00:00
|
|
|
|
export async function pickEmoji(src: HTMLElement, opts: ComponentProps<typeof MkEmojiPickerDialog>): Promise<string> {
|
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkEmojiPickerDialog, {
|
2020-11-14 05:32:01 +00:00
|
|
|
|
src,
|
2022-06-11 06:45:44 +00:00
|
|
|
|
...opts,
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}, {
|
|
|
|
|
done: emoji => {
|
|
|
|
|
resolve(emoji);
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 06:45:44 +00:00
|
|
|
|
export async function cropImage(image: Misskey.entities.DriveFile, options: {
|
|
|
|
|
aspectRatio: number;
|
2023-07-05 04:54:40 +00:00
|
|
|
|
uploadFolder?: string | null;
|
2022-06-11 06:45:44 +00:00
|
|
|
|
}): Promise<Misskey.entities.DriveFile> {
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkCropperDialog.vue')), {
|
2022-06-11 06:45:44 +00:00
|
|
|
|
file: image,
|
|
|
|
|
aspectRatio: options.aspectRatio,
|
2023-07-05 04:54:40 +00:00
|
|
|
|
uploadFolder: options.uploadFolder,
|
2022-06-11 06:45:44 +00:00
|
|
|
|
}, {
|
|
|
|
|
ok: x => {
|
|
|
|
|
resolve(x);
|
|
|
|
|
},
|
2024-07-04 04:14:49 +00:00
|
|
|
|
closed: () => dispose(),
|
|
|
|
|
});
|
2022-06-11 06:45:44 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 09:26:38 +00:00
|
|
|
|
export function popupMenu(items: MenuItem[], src?: HTMLElement | EventTarget | null, options?: {
|
2021-10-21 21:23:23 +00:00
|
|
|
|
align?: string;
|
|
|
|
|
width?: number;
|
2023-01-06 01:11:47 +00:00
|
|
|
|
onClosing?: () => void;
|
2023-03-02 06:05:05 +00:00
|
|
|
|
}): Promise<void> {
|
2024-07-12 07:25:44 +00:00
|
|
|
|
let returnFocusTo = getHTMLElementOrNull(src) ?? getHTMLElementOrNull(document.activeElement);
|
|
|
|
|
return new Promise(resolve => nextTick(() => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkPopupMenu, {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
items,
|
|
|
|
|
src,
|
2021-10-21 21:23:23 +00:00
|
|
|
|
width: options?.width,
|
2020-10-17 11:12:00 +00:00
|
|
|
|
align: options?.align,
|
2024-07-12 07:25:44 +00:00
|
|
|
|
returnFocusTo,
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}, {
|
|
|
|
|
closed: () => {
|
|
|
|
|
resolve();
|
|
|
|
|
dispose();
|
2024-07-12 07:25:44 +00:00
|
|
|
|
returnFocusTo = null;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
},
|
2023-01-06 01:11:47 +00:00
|
|
|
|
closing: () => {
|
2024-07-12 07:25:44 +00:00
|
|
|
|
options?.onClosing?.();
|
2023-01-06 01:11:47 +00:00
|
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
|
});
|
2024-07-12 07:25:44 +00:00
|
|
|
|
}));
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 09:26:38 +00:00
|
|
|
|
export function contextMenu(items: MenuItem[], ev: MouseEvent): Promise<void> {
|
2024-07-30 05:45:53 +00:00
|
|
|
|
if (
|
|
|
|
|
defaultStore.state.contextMenu === 'native' ||
|
|
|
|
|
(defaultStore.state.contextMenu === 'appWithShift' && !ev.shiftKey)
|
|
|
|
|
) {
|
|
|
|
|
return Promise.resolve();
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 07:25:44 +00:00
|
|
|
|
let returnFocusTo = getHTMLElementOrNull(ev.currentTarget ?? ev.target) ?? getHTMLElementOrNull(document.activeElement);
|
2020-10-17 11:12:00 +00:00
|
|
|
|
ev.preventDefault();
|
2024-07-12 07:25:44 +00:00
|
|
|
|
return new Promise(resolve => nextTick(() => {
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkContextMenu, {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
items,
|
|
|
|
|
ev,
|
|
|
|
|
}, {
|
|
|
|
|
closed: () => {
|
|
|
|
|
resolve();
|
|
|
|
|
dispose();
|
2024-07-12 07:25:44 +00:00
|
|
|
|
|
|
|
|
|
// MkModalを通していないのでここでフォーカスを戻す処理を行う
|
|
|
|
|
if (returnFocusTo != null) {
|
|
|
|
|
focusParent(returnFocusTo, true, false);
|
|
|
|
|
returnFocusTo = null;
|
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
},
|
|
|
|
|
});
|
2024-07-12 07:25:44 +00:00
|
|
|
|
}));
|
2020-10-17 11:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 06:05:05 +00:00
|
|
|
|
export function post(props: Record<string, any> = {}): Promise<void> {
|
2024-07-14 06:27:52 +00:00
|
|
|
|
pleaseLogin(undefined, (props.initialText || props.initialNote ? {
|
|
|
|
|
type: 'share',
|
|
|
|
|
params: {
|
|
|
|
|
text: props.initialText ?? props.initialNote.text,
|
|
|
|
|
visibility: props.initialVisibility ?? props.initialNote?.visibility,
|
|
|
|
|
localOnly: (props.initialLocalOnly || props.initialNote?.localOnly) ? '1' : '0',
|
|
|
|
|
},
|
|
|
|
|
} : undefined));
|
|
|
|
|
|
enhance: account migration (#10592)
* copy block and mute then create follow and unfollow jobs
* copy block and mute and update lists when detecting an account has moved
* no need to care promise orders
* refactor updating actor and target
* automatically accept if a locked account had accepted an old account
* fix exception format
* prevent the old account from calling some endpoints
* do not unfollow when moving
* adjust following and follower counts
* check movedToUri when receiving a follow request
* skip if no need to adjust
* Revert "disable account migration"
This reverts commit 2321214c98591bcfe1385c1ab5bf0ff7b471ae1d.
* fix translation specifier
* fix checking alsoKnownAs and uri
* fix updating account
* fix refollowing locked account
* decrease followersCount if followed by the old account
* adjust following and followers counts when unfollowing
* fix copying mutings
* prohibit moved account from moving again
* fix move service
* allow app creation after moving
* fix lint
* remove unnecessary field
* fix cache update
* add e2e test
* add e2e test of accepting the new account automatically
* force follow if any error happens
* remove unnecessary joins
* use Array.map instead of for const of
* ユーザーリストの移行は追加のみを行う
* nanka iroiro
* fix misskey-js?
* :v:
* 移行を行ったアカウントからのフォローリクエストの自動許可を調整
* newUriを外に出す
* newUriを外に出す2
* clean up
* fix newUri
* prevent moving if the destination account has already moved
* set alsoKnownAs via /i/update
* fix database initialization
* add return type
* prohibit updating alsoKnownAs after moving
* skip to add to alsoKnownAs if toUrl is known
* skip adding to the list if it already has
* use Acct.parse instead
* rename error code
* :art:
* 制限を5から10に緩和
* movedTo(Uri), alsoKnownAsはユーザーidを返すように
* test api res
* fix
* 元アカウントはミュートし続ける
* :art:
* unfollow
* fix
* getUserUriをUserEntityServiceに
* ?
* job!
* :art:
* instance => server
* accountMovedShort, forbiddenBecauseYouAreMigrated
* accountMovedShort
* fix test
* import, pin禁止
* 実績を凍結する
* clean up
* :v:
* change message
* ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに
* Revert "ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに"
This reverts commit 3bd7be35d8aa455cb01ae58f8172a71a50485db1.
* validateAlsoKnownAs
* 移行後2時間以内はインポート可能なファイルサイズを拡大
* clean up
* どうせactorをupdatePersonで更新するならupdatePersonしか移行処理を発行しないことにする
* handle error?
* リモートからの移行処理の条件を是正
* log, port
* fix
* fix
* enhance(dev): non-production環境でhttpサーバー間でもユーザー、ノートの連合が可能なように
* refactor (use checkHttps)
* MISSKEY_WEBFINGER_USE_HTTP
* Environment Variable readme
* NEVER USE IN PRODUCTION
* fix punyHost
* fix indent
* fix
* experimental
---------
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
2023-04-29 15:09:29 +00:00
|
|
|
|
showMovedDialog();
|
2024-02-28 09:26:38 +00:00
|
|
|
|
return new Promise(resolve => {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
// NOTE: MkPostFormDialogをdynamic importするとiOSでテキストエリアに自動フォーカスできない
|
2020-10-19 05:46:32 +00:00
|
|
|
|
// NOTE: ただ、dynamic importしない場合、MkPostFormDialogインスタンスが使いまわされ、
|
|
|
|
|
// Vueが渡されたコンポーネントに内部的に__propsというプロパティを生やす影響で、
|
|
|
|
|
// 複数のpost formを開いたときに場合によってはエラーになる
|
|
|
|
|
// もちろん複数のpost formを開けること自体Misskeyサイドのバグなのだが
|
2024-07-04 04:14:49 +00:00
|
|
|
|
const { dispose } = popup(MkPostFormDialog, props, {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
closed: () => {
|
|
|
|
|
resolve();
|
|
|
|
|
dispose();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const deckGlobalEvents = new EventEmitter();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
export function checkExistence(fileData: ArrayBuffer): Promise<any> {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
const data = new FormData();
|
|
|
|
|
data.append('md5', getMD5(fileData));
|
|
|
|
|
|
2024-01-04 09:32:46 +00:00
|
|
|
|
api('drive/files/find-by-hash', {
|
2020-10-17 11:12:00 +00:00
|
|
|
|
md5: getMD5(fileData)
|
|
|
|
|
}).then(resp => {
|
|
|
|
|
resolve(resp.length > 0 ? resp[0] : null);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}*/
|