2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2022-07-20 08:24:26 -05:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
2022-06-20 03:38:49 -05:00
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-18 20:06:12 -05:00
|
|
|
<MkSpacer :contentMax="700" :class="$style.main">
|
|
|
|
<div v-if="list" class="_gaps">
|
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts.settings }}</template>
|
|
|
|
|
|
|
|
<div class="_gaps">
|
|
|
|
<MkInput v-model="name">
|
|
|
|
<template #label>{{ i18n.ts.name }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkSwitch v-model="isPublic">{{ i18n.ts.public }}</MkSwitch>
|
|
|
|
<div class="_buttons">
|
|
|
|
<MkButton rounded primary @click="updateSettings">{{ i18n.ts.save }}</MkButton>
|
|
|
|
<MkButton rounded danger @click="deleteList()">{{ i18n.ts.delete }}</MkButton>
|
|
|
|
</div>
|
2021-12-02 05:09:12 -06:00
|
|
|
</div>
|
2023-05-18 20:06:12 -05:00
|
|
|
</MkFolder>
|
|
|
|
|
|
|
|
<MkFolder defaultOpen>
|
|
|
|
<template #label>{{ i18n.ts.members }}</template>
|
2023-07-14 23:53:09 -05:00
|
|
|
<template #caption>{{ i18n.t('nUsers', { n: `${list.userIds.length}/${$i?.policies['userEachUserListsLimit']}` }) }}</template>
|
2023-05-18 20:06:12 -05:00
|
|
|
|
|
|
|
<div class="_gaps_s">
|
|
|
|
<MkButton rounded primary style="margin: 0 auto;" @click="addUser()">{{ i18n.ts.addUser }}</MkButton>
|
2023-10-03 06:26:11 -05:00
|
|
|
|
|
|
|
<MkPagination ref="paginationEl" :pagination="membershipsPagination">
|
|
|
|
<template #default="{ items }">
|
|
|
|
<div class="_gaps_s">
|
|
|
|
<div v-for="item in items" :key="item.id">
|
|
|
|
<div :class="$style.userItem">
|
|
|
|
<MkA :class="$style.userItemBody" :to="`${userPage(item.user)}`">
|
|
|
|
<MkUserCardMini :user="item.user"/>
|
|
|
|
</MkA>
|
|
|
|
<button class="_button" :class="$style.menu" @click="showMembershipMenu(item, $event)"><i class="ti ti-dots"></i></button>
|
|
|
|
<button class="_button" :class="$style.remove" @click="removeUser(item, $event)"><i class="ti ti-x"></i></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MkPagination>
|
2023-03-02 05:47:24 -06:00
|
|
|
</div>
|
2023-05-18 20:06:12 -05:00
|
|
|
</MkFolder>
|
2023-03-02 05:47:24 -06:00
|
|
|
</div>
|
2023-05-18 20:06:12 -05:00
|
|
|
</MkSpacer>
|
2022-07-20 08:24:26 -05:00
|
|
|
</MkStickyContainer>
|
2020-01-29 13:37:25 -06:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
<script lang="ts" setup>
|
2023-05-18 20:06:12 -05:00
|
|
|
import { computed, ref, watch } from 'vue';
|
2023-09-03 23:33:38 -05:00
|
|
|
import * as Misskey from 'misskey-js';
|
2022-09-06 04:21:49 -05:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 02:37:43 -05:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { mainRouter } from '@/router.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { userPage } from '@/filters/user.js';
|
2023-02-28 23:22:53 -06:00
|
|
|
import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
2023-05-18 20:06:12 -05:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
|
|
|
import MkInput from '@/components/MkInput.vue';
|
2023-10-03 06:26:11 -05:00
|
|
|
import { userListsCache } from '@/cache.js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { $i } from '@/account.js';
|
|
|
|
import { defaultStore } from '@/store.js';
|
2023-12-26 06:40:27 -06:00
|
|
|
import MkPagination, { Paging } from '@/components/MkPagination.vue';
|
2023-10-03 06:26:11 -05:00
|
|
|
|
2023-07-14 23:53:09 -05:00
|
|
|
const {
|
|
|
|
enableInfiniteScroll,
|
|
|
|
} = defaultStore.reactiveState;
|
2022-06-20 03:38:49 -05:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
listId: string;
|
|
|
|
}>();
|
|
|
|
|
2023-10-03 06:26:11 -05:00
|
|
|
const paginationEl = ref<InstanceType<typeof MkPagination>>();
|
2023-12-06 23:42:09 -06:00
|
|
|
const list = ref<Misskey.entities.UserList | null>(null);
|
2023-05-18 20:06:12 -05:00
|
|
|
const isPublic = ref(false);
|
|
|
|
const name = ref('');
|
2023-10-03 06:26:11 -05:00
|
|
|
const membershipsPagination = {
|
|
|
|
endpoint: 'users/lists/get-memberships' as const,
|
|
|
|
limit: 30,
|
|
|
|
params: computed(() => ({
|
|
|
|
listId: props.listId,
|
|
|
|
})),
|
2023-12-26 06:40:27 -06:00
|
|
|
} satisfies Paging;
|
2022-06-20 03:38:49 -05:00
|
|
|
|
|
|
|
function fetchList() {
|
|
|
|
os.api('users/lists/show', {
|
|
|
|
listId: props.listId,
|
|
|
|
}).then(_list => {
|
2023-12-06 23:42:09 -06:00
|
|
|
list.value = _list;
|
|
|
|
name.value = list.value.name;
|
|
|
|
isPublic.value = list.value.isPublic;
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function addUser() {
|
|
|
|
os.selectUser().then(user => {
|
2023-12-06 23:42:09 -06:00
|
|
|
if (!list.value) return;
|
2022-06-20 03:38:49 -05:00
|
|
|
os.apiWithDialog('users/lists/push', {
|
2023-12-06 23:42:09 -06:00
|
|
|
listId: list.value.id,
|
2022-06-20 03:38:49 -05:00
|
|
|
userId: user.id,
|
|
|
|
}).then(() => {
|
2023-10-03 06:26:11 -05:00
|
|
|
paginationEl.value.reload();
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-10-03 06:26:11 -05:00
|
|
|
async function removeUser(item, ev) {
|
2023-02-28 23:22:53 -06:00
|
|
|
os.popupMenu([{
|
|
|
|
text: i18n.ts.remove,
|
|
|
|
icon: 'ti ti-x',
|
|
|
|
danger: true,
|
|
|
|
action: async () => {
|
2023-12-06 23:42:09 -06:00
|
|
|
if (!list.value) return;
|
2023-02-28 23:22:53 -06:00
|
|
|
os.api('users/lists/pull', {
|
2023-12-06 23:42:09 -06:00
|
|
|
listId: list.value.id,
|
2023-10-03 06:26:11 -05:00
|
|
|
userId: item.userId,
|
|
|
|
}).then(() => {
|
|
|
|
paginationEl.value.removeItem(item.id);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}], ev.currentTarget ?? ev.target);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function showMembershipMenu(item, ev) {
|
|
|
|
os.popupMenu([{
|
|
|
|
text: item.withReplies ? i18n.ts.hideRepliesToOthersInTimeline : i18n.ts.showRepliesToOthersInTimeline,
|
|
|
|
icon: item.withReplies ? 'ti ti-messages-off' : 'ti ti-messages',
|
|
|
|
action: async () => {
|
|
|
|
os.api('users/lists/update-membership', {
|
2023-12-06 23:42:09 -06:00
|
|
|
listId: list.value.id,
|
2023-10-03 06:26:11 -05:00
|
|
|
userId: item.userId,
|
|
|
|
withReplies: !item.withReplies,
|
2023-02-28 23:22:53 -06:00
|
|
|
}).then(() => {
|
2023-10-03 06:26:11 -05:00
|
|
|
paginationEl.value.updateItem(item.id, (old) => ({
|
|
|
|
...old,
|
|
|
|
withReplies: !item.withReplies,
|
|
|
|
}));
|
2023-02-28 23:22:53 -06:00
|
|
|
});
|
|
|
|
},
|
|
|
|
}], ev.currentTarget ?? ev.target);
|
2022-06-20 03:38:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
async function deleteList() {
|
2023-12-06 23:42:09 -06:00
|
|
|
if (!list.value) return;
|
2022-06-20 03:38:49 -05:00
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
2023-12-06 23:42:09 -06:00
|
|
|
text: i18n.t('removeAreYouSure', { x: list.value.name }),
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2023-03-24 02:58:57 -05:00
|
|
|
await os.apiWithDialog('users/lists/delete', {
|
2023-12-06 23:42:09 -06:00
|
|
|
listId: list.value.id,
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
2023-03-24 02:58:57 -05:00
|
|
|
userListsCache.delete();
|
2022-06-20 03:38:49 -05:00
|
|
|
mainRouter.push('/my/lists');
|
|
|
|
}
|
|
|
|
|
2023-05-18 20:06:12 -05:00
|
|
|
async function updateSettings() {
|
2023-12-06 23:42:09 -06:00
|
|
|
if (!list.value) return;
|
2023-05-18 20:06:12 -05:00
|
|
|
await os.apiWithDialog('users/lists/update', {
|
2023-12-06 23:42:09 -06:00
|
|
|
listId: list.value.id,
|
2023-05-18 20:06:12 -05:00
|
|
|
name: name.value,
|
|
|
|
isPublic: isPublic.value,
|
|
|
|
});
|
|
|
|
|
|
|
|
userListsCache.delete();
|
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
list.value.name = name.value;
|
|
|
|
list.value.isPublic = isPublic.value;
|
2023-05-18 20:06:12 -05:00
|
|
|
}
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
watch(() => props.listId, fetchList, { immediate: true });
|
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
const headerActions = computed(() => []);
|
2022-06-20 03:38:49 -05:00
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
const headerTabs = computed(() => []);
|
2022-06-20 03:38:49 -05:00
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
definePageMetadata(computed(() => list.value ? {
|
|
|
|
title: list.value.name,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-list',
|
2022-06-20 03:38:49 -05:00
|
|
|
} : null));
|
2020-01-29 13:37:25 -06:00
|
|
|
</script>
|
|
|
|
|
2023-02-28 23:22:53 -06:00
|
|
|
<style lang="scss" module>
|
2023-03-02 05:47:24 -06:00
|
|
|
.main {
|
2023-05-08 04:30:40 -05:00
|
|
|
min-height: calc(100cqh - (var(--stickyTop, 0px) + var(--stickyBottom, 0px)));
|
2023-03-02 05:47:24 -06:00
|
|
|
}
|
|
|
|
|
2023-02-28 23:22:53 -06:00
|
|
|
.userItem {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.userItemBody {
|
|
|
|
flex: 1;
|
|
|
|
min-width: 0;
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
text-decoration: none;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}
|
2023-02-28 23:22:53 -06:00
|
|
|
|
|
|
|
.remove {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
align-self: center;
|
|
|
|
}
|
2023-03-02 05:47:24 -06:00
|
|
|
|
2023-10-03 06:26:11 -05:00
|
|
|
.menu {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
align-self: center;
|
|
|
|
}
|
|
|
|
|
2023-07-14 23:53:09 -05:00
|
|
|
.more {
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: auto;
|
|
|
|
}
|
|
|
|
|
2023-03-02 05:47:24 -06:00
|
|
|
.footer {
|
|
|
|
-webkit-backdrop-filter: var(--blur, blur(15px));
|
|
|
|
backdrop-filter: var(--blur, blur(15px));
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
</style>
|