diff options
| author | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-05-10 11:25:00 +0900 |
|---|---|---|
| committer | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-05-10 11:25:00 +0900 |
| commit | 0a0d42bb4865320c728ff892ffe41a9bc060e3c2 (patch) | |
| tree | 8c2d235d602499f35dac53ffb431e18c9cfc340b /packages/frontend/src/pages/chat | |
| parent | refactor(frontend): use* 関数の格納場所のフォルダ名を composabl... (diff) | |
| download | misskey-0a0d42bb4865320c728ff892ffe41a9bc060e3c2.tar.gz misskey-0a0d42bb4865320c728ff892ffe41a9bc060e3c2.tar.bz2 misskey-0a0d42bb4865320c728ff892ffe41a9bc060e3c2.zip | |
enhance: 招待されているが参加していないルームを開いたときに、招待を承認するかどうか尋ねるように
Diffstat (limited to 'packages/frontend/src/pages/chat')
| -rw-r--r-- | packages/frontend/src/pages/chat/room.vue | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/packages/frontend/src/pages/chat/room.vue b/packages/frontend/src/pages/chat/room.vue index 64d3420166..ac13c5fac6 100644 --- a/packages/frontend/src/pages/chat/room.vue +++ b/packages/frontend/src/pages/chat/room.vue @@ -80,7 +80,7 @@ SPDX-License-Identifier: AGPL-3.0-only </button> </div> </Transition> - <XForm v-if="!initializing" :user="user" :room="room" :class="$style.form"/> + <XForm v-if="initialized" :user="user" :room="room" :class="$style.form"/> </div> </div> </template> @@ -127,7 +127,8 @@ export type NormalizedChatMessage = Omit<Misskey.entities.ChatMessageLite, 'from })[]; }; -const initializing = ref(true); +const initializing = ref(false); +const initialized = ref(false); const moreFetching = ref(false); const messages = ref<NormalizedChatMessage[]>([]); const canFetchMore = ref(false); @@ -171,7 +172,10 @@ function normalizeMessage(message: Misskey.entities.ChatMessageLite | Misskey.en async function initialize() { const LIMIT = 20; + if (initializing.value) return; + initializing.value = true; + initialized.value = false; if (props.userId) { const [u, m] = await Promise.all([ @@ -194,13 +198,44 @@ async function initialize() { connection.value.on('react', onReact); connection.value.on('unreact', onUnreact); } else { - const [r, m] = await Promise.all([ + const [rResult, mResult] = await Promise.allSettled([ misskeyApi('chat/rooms/show', { roomId: props.roomId }), misskeyApi('chat/messages/room-timeline', { roomId: props.roomId, limit: LIMIT }), ]); - room.value = r as Misskey.entities.ChatRoomsShowResponse; - messages.value = (m as Misskey.entities.ChatMessagesRoomTimelineResponse).map(x => normalizeMessage(x)); + if (rResult.status === 'rejected') { + os.alert({ + type: 'error', + text: i18n.ts.somethingHappened, + }); + initializing.value = false; + return; + } + + const r = rResult.value as Misskey.entities.ChatRoomsShowResponse; + + if (r.invitationExists) { + const confirm = await os.confirm({ + type: 'question', + title: r.name, + text: i18n.ts._chat.youAreNotAMemberOfThisRoomButInvited + '\n' + i18n.ts._chat.doYouAcceptInvitation, + }); + if (confirm.canceled) { + initializing.value = false; + router.push('/chat'); + return; + } else { + await os.apiWithDialog('chat/rooms/join', { roomId: r.id }); + initializing.value = false; + initialize(); + return; + } + } + + const m = mResult.status === 'fulfilled' ? mResult.value as Misskey.entities.ChatMessagesRoomTimelineResponse : []; + + room.value = r; + messages.value = m.map(x => normalizeMessage(x)); if (messages.value.length === LIMIT) { canFetchMore.value = true; @@ -217,6 +252,7 @@ async function initialize() { window.document.addEventListener('visibilitychange', onVisibilitychange); + initialized.value = true; initializing.value = false; } @@ -319,6 +355,12 @@ onMounted(() => { initialize(); }); +onActivated(() => { + if (!initialized.value) { + initialize(); + } +}); + onBeforeUnmount(() => { connection.value?.dispose(); window.document.removeEventListener('visibilitychange', onVisibilitychange); @@ -410,7 +452,7 @@ const headerActions = computed<PageHeaderItem[]>(() => [{ }]); definePage(computed(() => { - if (!initializing.value) { + if (initialized.value) { if (user.value) { return { userName: user.value, |