Merge branch 'notification-read-api' into swn

This commit is contained in:
tamaina 2021-11-19 20:43:41 +09:00
commit 0e4b72cf1c
353 changed files with 3496 additions and 2064 deletions

View file

@ -9,16 +9,15 @@ export function createAiScriptEnv(opts) {
USER_NAME: $i ? values.STR($i.name) : values.NULL,
USER_USERNAME: $i ? values.STR($i.username) : values.NULL,
'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => {
await os.dialog({
await os.alert({
type: type ? type.value : 'info',
title: title.value,
text: text.value,
});
}),
'Mk:confirm': values.FN_NATIVE(async ([title, text, type]) => {
const confirm = await os.dialog({
const confirm = await os.confirm({
type: type ? type.value : 'question',
showCancelButton: true,
title: title.value,
text: text.value,
});

View file

@ -14,21 +14,17 @@ export function getUserMenu(user) {
const t = i18n.locale.selectList; // なぜか後で参照すると null になるので最初にメモリに確保しておく
const lists = await os.api('users/lists/list');
if (lists.length === 0) {
os.dialog({
os.alert({
type: 'error',
text: i18n.locale.youHaveNoLists
});
return;
}
const { canceled, result: listId } = await os.dialog({
type: null,
const { canceled, result: listId } = await os.select({
title: t,
select: {
items: lists.map(list => ({
value: list.id, text: list.name
}))
},
showCancelButton: true
items: lists.map(list => ({
value: list.id, text: list.name
}))
});
if (canceled) return;
os.apiWithDialog('users/lists/push', {
@ -40,21 +36,17 @@ export function getUserMenu(user) {
async function inviteGroup() {
const groups = await os.api('users/groups/owned');
if (groups.length === 0) {
os.dialog({
os.alert({
type: 'error',
text: i18n.locale.youHaveNoGroups
});
return;
}
const { canceled, result: groupId } = await os.dialog({
type: null,
const { canceled, result: groupId } = await os.select({
title: i18n.locale.group,
select: {
items: groups.map(group => ({
value: group.id, text: group.name
}))
},
showCancelButton: true
items: groups.map(group => ({
value: group.id, text: group.name
}))
});
if (canceled) return;
os.apiWithDialog('users/groups/invite', {
@ -108,9 +100,8 @@ export function getUserMenu(user) {
}
async function getConfirmed(text: string): Promise<boolean> {
const confirm = await os.dialog({
const confirm = await os.confirm({
type: 'warning',
showCancelButton: true,
title: 'confirm',
text,
});

View file

@ -39,9 +39,8 @@ export class Hpml {
}), ...initAiLib(this)}, {
in: (q) => {
return new Promise(ok => {
os.dialog({
os.inputText({
title: q,
input: {}
}).then(({ canceled, result: a }) => {
ok(a);
});

View file

@ -3,9 +3,8 @@ import { i18n } from '@/i18n';
import * as os from '@/os';
export async function lookupUser() {
const { canceled, result } = await os.dialog({
const { canceled, result } = await os.inputText({
title: i18n.locale.usernameOrUserId,
input: true
});
if (canceled) return;
@ -18,7 +17,7 @@ export async function lookupUser() {
let _notFound = false;
const notFound = () => {
if (_notFound) {
os.dialog({
os.alert({
type: 'error',
text: i18n.locale.noSuchUser
});

View file

@ -1,11 +1,11 @@
import { $i } from '@/account';
import { i18n } from '@/i18n';
import { dialog } from '@/os';
import { alert } from '@/os';
export function pleaseLogin() {
if ($i) return;
dialog({
alert({
title: i18n.locale.signinRequired,
text: null
});

View file

@ -4,8 +4,8 @@ import { popup } from '@/os';
class ReactionPicker {
private src: Ref<HTMLElement | null> = ref(null);
private manualShowing = ref(false);
private onChosen?: Function;
private onClosed?: Function;
private onChosen?: (reaction: string) => void;
private onClosed?: () => void;
constructor() {
// nop
@ -30,7 +30,7 @@ class ReactionPicker {
});
}
public show(src: HTMLElement, onChosen: Function, onClosed: Function) {
public show(src: HTMLElement, onChosen: ReactionPicker['onChosen'], onClosed: ReactionPicker['onClosed']) {
this.src.value = src;
this.manualShowing.value = true;
this.onChosen = onChosen;

View file

@ -3,9 +3,8 @@ import { i18n } from '@/i18n';
import { router } from '@/router';
export async function search() {
const { canceled, result: query } = await os.dialog({
const { canceled, result: query } = await os.inputText({
title: i18n.locale.search,
input: true
});
if (canceled || query == null || query === '') return;
@ -35,7 +34,7 @@ export async function search() {
// TODO
//v.$root.$emit('warp', date);
os.dialog({
os.alert({
icon: 'fas fa-history',
iconOnly: true, autoClose: true
});

View file

@ -14,7 +14,7 @@ export function selectFile(src: any, label: string | null, multiple = false) {
Promise.all(promises).then(driveFiles => {
res(multiple ? driveFiles : driveFiles[0]);
}).catch(e => {
os.dialog({
os.alert({
type: 'error',
text: e
});
@ -38,11 +38,10 @@ export function selectFile(src: any, label: string | null, multiple = false) {
};
const chooseFileFromUrl = () => {
os.dialog({
os.inputText({
title: i18n.locale.uploadFromUrl,
input: {
placeholder: i18n.locale.uploadFromUrlDescription
}
type: 'url',
placeholder: i18n.locale.uploadFromUrlDescription
}).then(({ canceled, result: url }) => {
if (canceled) return;
@ -62,7 +61,7 @@ export function selectFile(src: any, label: string | null, multiple = false) {
marker
});
os.dialog({
os.alert({
title: i18n.locale.uploadFromUrlRequested,
text: i18n.locale.uploadFromUrlMayTakeTime
});

View file

@ -2,7 +2,7 @@ import * as os from '@/os';
import { i18n } from '@/i18n';
export function showSuspendedDialog() {
return os.dialog({
return os.alert({
type: 'error',
title: i18n.locale.yourAccountSuspendedTitle,
text: i18n.locale.yourAccountSuspendedDescription