Skip to content

Commit

Permalink
fix: アバターデコ周り
Browse files Browse the repository at this point in the history
  • Loading branch information
chan-mai committed Nov 22, 2024
1 parent ebedc0e commit 8058b87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 9 additions & 0 deletions packages/frontend/src/pages/avatar-decoration-edit-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkAvatar style="width: 60px; height: 60px;" :user="$i" :decorations="url != '' ? [{ url }] : []" forceShowDecoration/>
</div>
</div>
<MkButton rounded style="margin: 0 auto;" @click="selectImage(avatarDecoration, $event)">{{ i18n.ts.selectFile }}</MkButton>
<MkInput v-model="name">
<template #label>{{ i18n.ts.name }}</template>
</MkInput>
Expand Down Expand Up @@ -92,11 +93,19 @@ const name = ref<string>(props.avatarDecoration ? props.avatarDecoration.name :
const description = ref<string>(props.avatarDecoration ? props.avatarDecoration.description : '');
const roleIdsThatCanBeUsedThisDecoration = ref(props.avatarDecoration ? props.avatarDecoration.roleIdsThatCanBeUsedThisDecoration : []);
const rolesThatCanBeUsedThisDecoration = ref<Misskey.entities.Role[]>([]);
import { selectFile } from '@/scripts/select-file.js';

watch(roleIdsThatCanBeUsedThisDecoration, async () => {
rolesThatCanBeUsedThisDecoration.value = (await Promise.all(roleIdsThatCanBeUsedThisDecoration.value.map((id) => misskeyApi('admin/roles/show', { roleId: id }).catch(() => null)))).filter(x => x != null);
}, { immediate: true });

// ファイル選択
async function selectImage(decoration, ev) {
let file = await selectFile(ev.currentTarget ?? ev.target, null);
name.value = file.name.replace(/\.(.+)$/, '');
url.value = file.url;
}

async function addRole() {
const roles = await misskeyApi('admin/roles/list');
const currentRoleIds = rolesThatCanBeUsedThisDecoration.value.map(x => x.id);
Expand Down
9 changes: 0 additions & 9 deletions packages/frontend/src/pages/avatar-decorations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ SPDX-License-Identifier: AGPL-3.0-only
@click="edit(avatarDecoration)"
>
<div :class="$style.decorationName"><MkCondensedLine :minScale="0.5">{{ avatarDecoration.name }}</MkCondensedLine></div>
<MkButton rounded style="margin: 0 auto;" @click="selectImage(avatarDecoration, $event)">{{ i18n.ts.selectFile }}</MkButton>
<MkAvatar style="width: 60px; height: 60px;" :user="$i" :decorations="[{ url: avatarDecoration.url }]" forceShowDecoration/>
</div>
</div>
Expand All @@ -34,19 +33,11 @@ import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { selectFile } from '@/scripts/select-file.js';

const $i = signinRequired();

const avatarDecorations = ref<Misskey.entities.AdminAvatarDecorationsListResponse>([]);

// ファイル選択
async function selectImage(decoration, ev) {
let file = await selectFile(ev.currentTarget ?? ev.target, null);
decoration.name = file.name.replace(/\.(.+)$/, '');
decoration.url = file.url;
}

function load() {
misskeyApi('admin/avatar-decorations/list').then(_avatarDecorations => {
avatarDecorations.value = _avatarDecorations;
Expand Down

0 comments on commit 8058b87

Please sign in to comment.