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
99
100
101
102
103
104
|
<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<div class="_gaps">
<MkInput v-model="name_" :disabled="!isOwner">
<template #label>{{ i18n.ts.name }}</template>
</MkInput>
<MkTextarea v-model="description_" :disabled="!isOwner">
<template #label>{{ i18n.ts.description }}</template>
</MkTextarea>
<MkButton v-if="isOwner" primary @click="save">{{ i18n.ts.save }}</MkButton>
<hr>
<MkButton v-if="isOwner || ($i.isAdmin || $i.isModerator)" danger @click="del">{{ i18n.ts._chat.deleteRoom }}</MkButton>
<MkSwitch v-if="!isOwner" v-model="isMuted">
<template #label>{{ i18n.ts._chat.muteThisRoom }}</template>
</MkSwitch>
</div>
</template>
<script lang="ts" setup>
import { computed, onMounted, ref, watch } 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 * as os from '@/os.js';
import { ensureSignin } from '@/i.js';
import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import { useRouter } from '@/router.js';
const router = useRouter();
const $i = ensureSignin();
const props = defineProps<{
room: Misskey.entities.ChatRoom;
}>();
const isOwner = computed(() => {
return props.room.ownerId === $i.id;
});
const name_ = ref(props.room.name);
const description_ = ref(props.room.description);
function save() {
os.apiWithDialog('chat/rooms/update', {
roomId: props.room.id,
name: name_.value,
description: description_.value,
});
}
async function del() {
const { canceled } = await os.confirm({
type: 'warning',
text: i18n.ts.areYouSure,
});
if (canceled) return;
misskeyApi('chat/rooms/delete', {
roomId: props.room.id,
});
router.push('/chat');
}
const isMuted = ref(props.room.isMuted);
watch(isMuted, async () => {
await os.apiWithDialog('chat/rooms/mute', {
roomId: props.room.id,
mute: isMuted.value,
});
});
onMounted(async () => {
});
</script>
<style lang="scss" module>
.membership {
display: flex;
}
.membershipBody {
flex: 1;
min-width: 0;
margin-right: 8px;
&:hover {
text-decoration: none;
}
}
</style>
|