blob: 5a574068cb42ae8c6af7c8beafc3115c15228142 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<div class="_gaps">
<MkButton v-if="isOwner" primary rounded style="margin: 0 auto;" @click="emit('inviteUser')"><i class="ti ti-plus"></i> {{ i18n.ts._chat.inviteUser }}</MkButton>
<MkA :class="$style.membershipBody" :to="`${userPage(room.owner)}`">
<MkUserCardMini :user="room.owner"/>
</MkA>
<hr v-if="memberships.length > 0">
<div v-for="membership in memberships" :key="membership.id" :class="$style.membership">
<MkA :class="$style.membershipBody" :to="`${userPage(membership.user!)}`">
<MkUserCardMini :user="membership.user!"/>
</MkA>
</div>
<template v-if="isOwner">
<hr>
<div>{{ i18n.ts._chat.sentInvitations }}</div>
<div v-for="invitation in invitations" :key="invitation.id" :class="$style.invitation">
<MkA :class="$style.invitationBody" :to="`${userPage(invitation.user)}`">
<MkUserCardMini :user="invitation.user"/>
</MkA>
</div>
</template>
</div>
</template>
<script lang="ts" setup>
import { computed, onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js';
import MkButton from '@/components/MkButton.vue';
import { i18n } from '@/i18n.js';
import { misskeyApi } from '@/utility/misskey-api.js';
import MkUserCardMini from '@/components/MkUserCardMini.vue';
import { userPage } from '@/filters/user.js';
import { ensureSignin } from '@/i.js';
const $i = ensureSignin();
const props = defineProps<{
room: Misskey.entities.ChatRoom;
}>();
const emit = defineEmits<{
(ev: 'inviteUser'): void,
}>();
const isOwner = computed(() => {
return props.room.ownerId === $i.id;
});
const memberships = ref<Misskey.entities.ChatRoomMembership[]>([]);
const invitations = ref<Misskey.entities.ChatRoomInvitation[]>([]);
onMounted(async () => {
memberships.value = await misskeyApi('chat/rooms/members', {
roomId: props.room.id,
limit: 50,
});
if (isOwner.value) {
invitations.value = await misskeyApi('chat/rooms/invitations/outbox', {
roomId: props.room.id,
limit: 50,
});
}
});
</script>
<style lang="scss" module>
.membership {
display: flex;
}
.membershipBody {
flex: 1;
min-width: 0;
margin-right: 8px;
}
.invitation {
display: flex;
}
.invitationBody {
flex: 1;
min-width: 0;
margin-right: 8px;
}
</style>
|