Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(frontend): os.ts周りのリファクタリング #13186

Merged
merged 17 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/frontend/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export async function refreshAccount() {
export async function login(token: Account['token'], redirect?: string) {
const showing = ref(true);
popup(defineAsyncComponent(() => import('@/components/MkWaitingDialog.vue')), {
success: false,
success: ref(false),
showing: showing,
}, {}, 'closed');
if (_DEV_) console.log('logging as token ', token);
Expand Down Expand Up @@ -290,7 +290,7 @@ export async function openAccountMenu(opts: {
text: i18n.ts.profile,
to: `/@${ $i.username }`,
avatar: $i,
}, { type: 'divider' }, ...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises, {
}, { type: 'divider' as const }, ...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises, {
type: 'parent' as const,
icon: 'ti ti-plus',
text: i18n.ts.addAccount,
Expand Down
18 changes: 3 additions & 15 deletions packages/frontend/src/components/MkDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<template v-if="select.items">
<option v-for="item in select.items" :value="item.value">{{ item.text }}</option>
</template>
<template v-else>
<optgroup v-for="groupedItem in select.groupedItems" :label="groupedItem.label">
<option v-for="item in groupedItem.items" :value="item.value">{{ item.text }}</option>
</optgroup>
</template>
</MkSelect>
<div v-if="(showOkButton || showCancelButton) && !actions" :class="$style.buttons">
<MkButton v-if="showOkButton" data-cy-modal-dialog-ok inline primary rounded :autofocus="!input && !select" :disabled="okButtonDisabledReason" @click="ok">{{ okText ?? ((showCancelButton || input || select) ? i18n.ts.ok : i18n.ts.gotIt) }}</MkButton>
Expand All @@ -64,7 +59,7 @@ import MkSelect from '@/components/MkSelect.vue';
import { i18n } from '@/i18n.js';

type Input = {
type: 'text' | 'number' | 'password' | 'email' | 'url' | 'date' | 'time' | 'search' | 'datetime-local';
type?: 'text' | 'number' | 'password' | 'email' | 'url' | 'date' | 'time' | 'search' | 'datetime-local';
placeholder?: string | null;
autocomplete?: string;
default: string | number | null;
Expand All @@ -74,22 +69,15 @@ type Input = {

type Select = {
items: {
value: string;
value: any;
text: string;
}[];
groupedItems: {
label: string;
items: {
value: string;
text: string;
}[];
}[];
default: string | null;
};

const props = withDefaults(defineProps<{
type?: 'success' | 'error' | 'warning' | 'info' | 'question' | 'waiting';
title: string;
title?: string;
text?: string;
input?: Input;
select?: Select;
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/components/MkDriveSelectDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ withDefaults(defineProps<{
});

const emit = defineEmits<{
(ev: 'done', r?: Misskey.entities.DriveFile[]): void;
(ev: 'done', r?: Misskey.entities.DriveFile[] | Misskey.entities.DriveFolder[]): void;
(ev: 'closed'): void;
}>();

const dialog = shallowRef<InstanceType<typeof MkModalWindow>>();

const selected = ref<Misskey.entities.DriveFile[]>([]);
const selected = ref<Misskey.entities.DriveFile[] | Misskey.entities.DriveFolder[]>([]);

function ok() {
emit('done', selected.value);
Expand All @@ -57,7 +57,7 @@ function cancel() {
dialog.value?.close();
}

function onChangeSelection(files: Misskey.entities.DriveFile[]) {
selected.value = files;
function onChangeSelection(v: Misskey.entities.DriveFile[] | Misskey.entities.DriveFolder[]) {
selected.value = v;
}
</script>
4 changes: 2 additions & 2 deletions packages/frontend/src/components/MkEmojiPickerDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ const props = withDefaults(defineProps<{
});

const emit = defineEmits<{
(ev: 'done', v: any): void;
(ev: 'done', v: string): void;
(ev: 'close'): void;
(ev: 'closed'): void;
}>();

const modal = shallowRef<InstanceType<typeof MkModal>>();
const picker = shallowRef<InstanceType<typeof MkEmojiPicker>>();

function chosen(emoji: any) {
function chosen(emoji: string) {
emit('done', emoji);
if (props.choseAndClose) {
modal.value?.close();
Expand Down
49 changes: 0 additions & 49 deletions packages/frontend/src/components/MkEmojiPickerWindow.vue

This file was deleted.

6 changes: 3 additions & 3 deletions packages/frontend/src/components/MkWaitingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import { watch, shallowRef } from 'vue';
import { Ref, watch, shallowRef } from 'vue';
import MkModal from '@/components/MkModal.vue';

const modal = shallowRef<InstanceType<typeof MkModal>>();

const props = defineProps<{
success: boolean;
showing: boolean;
success: Ref<boolean>;
showing: Ref<boolean>;
zyoshoka marked this conversation as resolved.
Show resolved Hide resolved
text?: string;
}>();

Expand Down
Loading
Loading