2023-07-27 08:31:52 +03:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-05-19 04:06:12 +03:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-19 10:20:53 +03:00
|
|
|
<MKSpacer v-if="!(typeof error === 'undefined')" :contentMax="1200">
|
2023-05-19 04:06:12 +03:00
|
|
|
<div :class="$style.root">
|
2023-06-09 08:00:53 +03:00
|
|
|
<img :class="$style.img" :src="serverErrorImageUrl" class="_ghost"/>
|
2023-05-19 04:06:12 +03:00
|
|
|
<p :class="$style.text">
|
|
|
|
<i class="ti ti-alert-triangle"></i>
|
|
|
|
{{ i18n.ts.nothing }}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</MKSpacer>
|
2023-05-19 10:20:53 +03:00
|
|
|
<MkSpacer v-else-if="list" :contentMax="700" :class="$style.main">
|
2023-05-19 04:06:12 +03:00
|
|
|
<div v-if="list" class="members _margin">
|
|
|
|
<div :class="$style.member_text">{{ i18n.ts.members }}</div>
|
|
|
|
<div class="_gaps_s">
|
|
|
|
<div v-for="user in users" :key="user.id" :class="$style.userItem">
|
|
|
|
<MkA :class="$style.userItemBody" :to="`${userPage(user)}`">
|
|
|
|
<MkUserCardMini :user="user"/>
|
|
|
|
</MkA>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-19 10:20:53 +03:00
|
|
|
<MkButton v-if="list.isLiked" v-tooltip="i18n.ts.unlike" inline :class="$style.button" asLike primary @click="unlike()"><i class="ti ti-heart-off"></i><span v-if="list.likedCount > 0" class="count">{{ list.likedCount }}</span></MkButton>
|
|
|
|
<MkButton v-if="!list.isLiked" v-tooltip="i18n.ts.like" inline :class="$style.button" asLike @click="like()"><i class="ti ti-heart"></i><span v-if="1 > 0" class="count">{{ list.likedCount }}</span></MkButton>
|
2023-05-19 04:06:12 +03:00
|
|
|
<MkButton inline @click="create()"><i class="ti ti-download" :class="$style.import"></i>{{ i18n.ts.import }}</MkButton>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-07 07:42:09 +02:00
|
|
|
import { watch, computed, ref } from 'vue';
|
2023-12-26 07:19:35 +02:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-09-19 10:37:43 +03:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 11:32:46 +02:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 10:37:43 +03:00
|
|
|
import { userPage } from '@/filters/user.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2023-05-19 04:06:12 +03:00
|
|
|
import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 10:37:43 +03:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { serverErrorImageUrl } from '@/instance.js';
|
2023-05-19 04:06:12 +03:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
listId: string;
|
|
|
|
}>();
|
|
|
|
|
2023-12-26 07:19:35 +02:00
|
|
|
const list = ref<Misskey.entities.UserList | null>(null);
|
2023-12-07 07:42:09 +02:00
|
|
|
const error = ref();
|
2023-12-26 07:19:35 +02:00
|
|
|
const users = ref<Misskey.entities.UserDetailed[]>([]);
|
2023-05-19 04:06:12 +03:00
|
|
|
|
|
|
|
function fetchList(): void {
|
2024-01-04 11:32:46 +02:00
|
|
|
misskeyApi('users/lists/show', {
|
2023-05-19 04:06:12 +03:00
|
|
|
listId: props.listId,
|
|
|
|
forPublic: true,
|
|
|
|
}).then(_list => {
|
2023-12-07 07:42:09 +02:00
|
|
|
list.value = _list;
|
2024-01-04 11:32:46 +02:00
|
|
|
misskeyApi('users/show', {
|
2023-12-07 07:42:09 +02:00
|
|
|
userIds: list.value.userIds,
|
2023-05-19 04:06:12 +03:00
|
|
|
}).then(_users => {
|
2023-12-07 07:42:09 +02:00
|
|
|
users.value = _users;
|
2023-05-19 04:06:12 +03:00
|
|
|
});
|
|
|
|
}).catch(err => {
|
2023-12-07 07:42:09 +02:00
|
|
|
error.value = err;
|
2023-05-19 04:06:12 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function like() {
|
|
|
|
os.apiWithDialog('users/lists/favorite', {
|
2023-12-07 07:42:09 +02:00
|
|
|
listId: list.value.id,
|
2023-05-19 04:06:12 +03:00
|
|
|
}).then(() => {
|
2023-12-07 07:42:09 +02:00
|
|
|
list.value.isLiked = true;
|
|
|
|
list.value.likedCount++;
|
2023-05-19 04:06:12 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function unlike() {
|
|
|
|
os.apiWithDialog('users/lists/unfavorite', {
|
2023-12-07 07:42:09 +02:00
|
|
|
listId: list.value.id,
|
2023-05-19 04:06:12 +03:00
|
|
|
}).then(() => {
|
2023-12-07 07:42:09 +02:00
|
|
|
list.value.isLiked = false;
|
|
|
|
list.value.likedCount--;
|
2023-05-19 04:06:12 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async function create() {
|
|
|
|
const { canceled, result: name } = await os.inputText({
|
|
|
|
title: i18n.ts.enterListName,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2023-12-07 07:42:09 +02:00
|
|
|
await os.apiWithDialog('users/lists/create-from-public', { name: name, listId: list.value.id });
|
2023-05-19 04:06:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
watch(() => props.listId, fetchList, { immediate: true });
|
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
const headerActions = computed(() => []);
|
2023-05-19 04:06:12 +03:00
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
const headerTabs = computed(() => []);
|
2023-05-19 04:06:12 +03:00
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
definePageMetadata(computed(() => list.value ? {
|
|
|
|
title: list.value.name,
|
2023-05-19 04:06:12 +03:00
|
|
|
icon: 'ti ti-list',
|
|
|
|
} : null));
|
|
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
|
|
.main {
|
|
|
|
min-height: calc(100cqh - (var(--stickyTop, 0px) + var(--stickyBottom, 0px)));
|
|
|
|
}
|
|
|
|
|
|
|
|
.userItem {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.userItemBody {
|
|
|
|
flex: 1;
|
|
|
|
min-width: 0;
|
|
|
|
margin-right: 8px;
|
2023-07-08 01:08:16 +03:00
|
|
|
|
2023-05-19 04:06:12 +03:00
|
|
|
&:hover {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.member_text {
|
|
|
|
margin: 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.root {
|
|
|
|
padding: 32px;
|
|
|
|
text-align: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.text {
|
|
|
|
margin: 0 0 8px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.img {
|
|
|
|
vertical-align: bottom;
|
|
|
|
width: 128px;
|
|
|
|
height: 128px;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
border-radius: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.button {
|
|
|
|
margin-right: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.import {
|
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
</style>
|