Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ウェビナー仮実装: サーバー接続部分はよいと思うんだけど、見た目の部分と上位コンポーネントでの変数管理がよくわかんなかった #4494

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 52 additions & 15 deletions src/components/Main/MainView/QallView/ParticipantList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@
import { ref, watch, useCssModule, computed } from 'vue'
import type { User } from '@traptitech/traq'

const { participant, trackInfo } = defineProps<{
// 追加: useQall をimportし、changeParticipantRoleを使う
import { useQall } from '/@/composables/qall/useQall'

Check warning on line 9 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L9

Added line #L9 was not covered by tests

const props = defineProps<{

Check warning on line 11 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L11

Added line #L11 was not covered by tests
participant: User
trackInfo: TrackInfo
roomId: string
isWebinar: boolean
iHavePermission: boolean // 自分が発言権限を持っているかどうか
participantCanPublish: boolean // 表示する相手の発言権限
}>()

const { participant, trackInfo, roomId, isWebinar, iHavePermission, participantCanPublish } = props

Check warning on line 20 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L20

Added line #L20 was not covered by tests

const { changeParticipantRole } = useQall()

Check warning on line 22 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L22

Added line #L22 was not covered by tests

const { getStore, setStore } = useUserVolume()

const parseToFloat = (value: number | string): number => {
Expand Down Expand Up @@ -62,23 +73,50 @@
[style.volumeSlider]: true,
[style.muted]: isMuted.value
}))

/**
* 発言権限のトグル (チェックボックスの変更)
*/
const publishCheck = ref(participantCanPublish)

Check warning on line 80 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L80

Added line #L80 was not covered by tests

const togglePublish = async () => {

Check warning on line 82 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L82

Added line #L82 was not covered by tests
// もし自分が権限を持ってなければ変更不可
if (!iHavePermission) return

Check warning on line 84 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L84

Added line #L84 was not covered by tests

publishCheck.value = !publishCheck.value
try {
await changeParticipantRole(roomId, [
{
identity: participant.name, // name が identityとして識別されてる想定
canPublish: publishCheck.value
}
])
} catch (e) {
console.error('Failed to change participant role:', e)

Check warning on line 95 in src/components/Main/MainView/QallView/ParticipantList.vue

View workflow job for this annotation

GitHub Actions / run lint

Unexpected console statement
}
}

Check warning on line 97 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L86-L97

Added lines #L86 - L97 were not covered by tests
</script>

<template>
<div :class="$style.container">
<div :class="$style.leftSide">
<user-icon :size="40" :user-id="participant.id" />
<span :class="$style.userName">{{ participant.displayName }}</span>
<!-- TODO: Qall: ミュートを実装する -->
<!-- <button :class="$style.micIconButton">
<a-icon v-if="isMuted" name="microphone-off" mdi />
</button> -->
<!-- (Optional) mic or speaker icon if needed -->

Check warning on line 105 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L105

Added line #L105 was not covered by tests
</div>

<div :class="$style.rightSide">
<!-- <button :class="$style.iconButton" @click="toggleMute(trackInfo)">
<a-icon v-if="isMuted" name="volume-off" :size="24" mdi />
<a-icon v-else name="volume-high" mdi :size="24" />
</button> -->
<!-- If isWebinar && iHavePermission, show a checkbox to toggle participant's canPublish -->
<div v-if="isWebinar && iHavePermission" :class="$style.checkboxContainer">
<input
type="checkbox"
:checked="publishCheck"
@change="togglePublish"
/>
<label>発言権限</label>
</div>

Check warning on line 117 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L109-L117

Added lines #L109 - L117 were not covered by tests

<!-- volume slider -->

Check warning on line 119 in src/components/Main/MainView/QallView/ParticipantList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/ParticipantList.vue#L119

Added line #L119 was not covered by tests
<input
v-model="volume"
type="range"
Expand Down Expand Up @@ -128,12 +166,11 @@
gap: 8px;
}

.iconButton {
width: 40px;
height: 40px;
border: none;
background: transparent;
cursor: pointer;
/* checkbox style */
.checkboxContainer {
display: flex;
align-items: center;
gap: 4px;
}

.volumeSlider {
Expand Down
32 changes: 31 additions & 1 deletion src/composables/qall/useQall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,39 @@
const text = await res.text()
throw new Error(`POST /soundboard/play failed: ${text}`)
}
// 正常時に IngressInfo(ingressId, url, streamKey)が返る想定
return await res.json()
}

/**
* PATCH /rooms/{roomId}/participants
* ルームでの発言権限を変更
*
* participants:
* [{ identity: "xxx", canPublish: true }, ...]
*/
const changeParticipantRole = async (
roomId: string,
participants: Array<{ identity: string; canPublish: boolean }>

Check warning on line 208 in src/composables/qall/useQall.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useQall.ts#L206-L208

Added lines #L206 - L208 were not covered by tests
): Promise<{
results: Array<{
participantId: string
status: 'success' | 'error'
errorMessage?: string
}>
}> => {
const res = await qallFetch(`/api/rooms/${roomId}/participants`, {
method: 'PATCH',
body: JSON.stringify(participants)

Check warning on line 218 in src/composables/qall/useQall.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useQall.ts#L215-L218

Added lines #L215 - L218 were not covered by tests
// headers → デフォルト application/json
})
if (!res.ok) {
const text = await res.text()
throw new Error(`PATCH /rooms/${roomId}/participants failed: ${text}`)
}
return await res.json()
}

Check warning on line 226 in src/composables/qall/useQall.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useQall.ts#L220-L226

Added lines #L220 - L226 were not covered by tests

// その他既存のWebSocketなど
const purifyRoomData = async (data: RoomsWithParticipants): Promise<Rooms> => {
if (!data) return []
await bothChannelsMapInitialFetchPromise.value
Expand Down Expand Up @@ -318,6 +347,7 @@
getSoundboardList,
postSoundboard,
postSoundboardPlay,
changeParticipantRole,

Check warning on line 350 in src/composables/qall/useQall.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useQall.ts#L350

Added line #L350 was not covered by tests
isMicOn,
isCameraOn,
isScreenSharing,
Expand Down
Loading