mizzkey/packages/frontend/src/pages/my-lists/index.vue

151 lines
4.4 KiB
Vue
Raw Normal View History

<!--
2024-02-12 11:37:45 +09:00
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
2022-07-20 22:24:26 +09:00
<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
2023-05-19 20:52:15 +09:00
<MkSpacer :contentMax="700">
2024-01-28 07:56:32 +09:00
<MkFoldableSection style="margin-bottom: 32px;">
<template #header>{{ i18n.ts.favoriteLists }}</template>
<div class="_gaps">
<div v-if="feautureList.length === 0" class="empty">
<div class="_fullinfo">
<img :src="infoImageUrl" class="_ghost"/>
<div>{{ i18n.ts.nothing }}</div>
</div>
</div>
<div v-if="feautureList.length > 0" class="_gaps">
<MkA v-for="list in feautureList" :key="list.id" class="_panel" :class="$style.list" :to="`/list/${ list.id }`">
<div style="margin-bottom: 4px;">{{ list.name }} <span :class="$style.nUsers">({{ i18n.tsx.nUsers({ n: `${list.userIds.length}` }) }})</span></div>
<MkAvatars :userIds="list.userIds" :limit="10"/>
</MkA>
</div>
</div>
2024-01-28 07:56:32 +09:00
</MkFoldableSection>
<MkFoldableSection style="margin-bottom: 32px;">
<template #header>{{ i18n.ts.localListList }}</template>
<div class="_gaps">
<div v-if="localList.length === 0" class="empty">
<div class="_fullinfo">
<img :src="infoImageUrl" class="_ghost"/>
<div>{{ i18n.ts.nothing }}</div>
</div>
</div>
2024-01-28 07:56:32 +09:00
<div v-if="localList.length > 0" class="_gaps">
<MkA v-for="list in localList" :key="list.id" class="_panel" :class="$style.list" :to="`/list/${ list.id }`">
<div style="margin-bottom: 4px;">{{ list.name }} <span :class="$style.nUsers">({{ i18n.tsx.nUsers({ n: `${list.userIds.length}` }) }})</span></div>
<MkAvatars :userIds="list.userIds" :limit="10"/>
</MkA>
</div>
</div>
</MkFoldableSection>
<MkFoldableSection>
<template #header>{{ i18n.ts.myLists }}</template>
<div class="_gaps">
<div v-if="items.length === 0" class="empty">
<div class="_fullinfo">
<img :src="infoImageUrl" class="_ghost"/>
<div>{{ i18n.ts.nothing }}</div>
</div>
</div>
2024-01-28 07:56:32 +09:00
<div v-if="items.length > 0" class="_gaps">
<MkA v-for="list in items" :key="list.id" class="_panel" :class="$style.list" :to="`/my/lists/${ list.id }`">
<div style="margin-bottom: 4px;">{{ list.name }} <span :class="$style.nUsers">({{ i18n.tsx.nUsers({ n: `${list.userIds.length}/${$i.policies['userEachUserListsLimit']}` }) }})</span></div>
<MkAvatars :userIds="list.userIds" :limit="10"/>
</MkA>
</div>
</div>
2024-01-28 07:56:32 +09:00
</MkFoldableSection>
2022-07-20 22:24:26 +09:00
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { onActivated, computed } from 'vue';
import MkAvatars from '@/components/MkAvatars.vue';
2023-09-19 16:37:43 +09:00
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
2024-01-28 07:56:32 +09:00
import { userFavoriteListsCache, userListsCache } from '@/cache.js';
2023-09-19 16:37:43 +09:00
import { infoImageUrl } from '@/instance.js';
2024-01-04 15:30:40 +09:00
import { signinRequired } from '@/account.js';
2024-01-28 07:56:32 +09:00
import MkFoldableSection from '@/components/MkFoldableSection.vue';
import { misskeyApi } from '@/scripts/misskey-api.js';
2024-01-04 15:30:40 +09:00
const $i = signinRequired();
const items = computed(() => userListsCache.value.value ?? []);
2024-01-28 07:56:32 +09:00
const localList = await misskeyApi('users/lists/list', { publicAll: true });
const feautureList = computed(() => userFavoriteListsCache.value.value ?? []);
function fetch() {
2023-09-11 14:55:18 +09:00
userListsCache.fetch();
2024-01-28 07:56:32 +09:00
userFavoriteListsCache.delete();
userFavoriteListsCache.fetch();
}
fetch();
async function create() {
const { canceled, result: name } = await os.inputText({
title: i18n.ts.enterListName,
});
if (canceled) return;
await os.apiWithDialog('users/lists/create', { name: name });
2023-03-24 16:58:57 +09:00
userListsCache.delete();
fetch();
}
const headerActions = computed(() => [{
asFullButton: true,
icon: 'ti ti-refresh',
text: i18n.ts.reload,
handler: () => {
userListsCache.delete();
fetch();
},
2024-01-28 07:56:32 +09:00
}, {
asFullButton: true,
icon: 'ti ti-plus',
text: i18n.ts.createList,
handler: create,
}]);
const headerTabs = computed(() => []);
definePageMetadata(() => ({
2024-01-28 07:56:32 +09:00
title: i18n.ts._exportOrImport.userLists,
icon: 'ti ti-list',
}));
onActivated(() => {
fetch();
});
</script>
2023-05-27 11:35:26 +09:00
<style lang="scss" module>
.list {
display: block;
padding: 16px;
border: solid 1px var(--divider);
border-radius: 6px;
margin-bottom: 8px;
2021-08-11 00:21:24 +09:00
2023-05-27 11:35:26 +09:00
&:hover {
border: solid 1px var(--accent);
text-decoration: none;
}
}
.nUsers {
font-size: .9em;
opacity: .7;
}
</style>