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

メッセージビューワーの実装 #4468

Merged
merged 1 commit into from
Jan 23, 2025
Merged
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
1 change: 0 additions & 1 deletion src/components/Main/MainView/ChannelView/ChannelView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
:pinned-messages="pinnedMessages"
:typing-users="typingUsers"
/>
<!-- <SubQallView /> -->
</template>
<template #sidebar>
<channel-sidebar
Expand Down
149 changes: 149 additions & 0 deletions src/components/Main/MainView/QallView/QallMessageView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<template>
<div :class="$style.container">
<scroll-loading-bar
:class="$style.loadingBar"
:show="isLoading && isMessageShow"
/>
<transition name="fade-bottom" mode="out-in">
<messages-scroller
v-show="isMessageShow"
ref="scrollerEle"
:message-ids="messageIds"
:is-reached-end="isReachedEnd"
:is-reached-latest="isReachedLatest"
:is-loading="isLoading"
:last-loading-direction="lastLoadingDirection"
@request-load-former="onLoadFormerMessagesRequest"
@request-load-latter="onLoadLatterMessagesRequest"
@scroll-passive="handleScroll"
@reset-is-reached-latest="resetIsReachedLatest"
>
<template
#default="{ messageId, onChangeHeight, onEntryMessageLoaded }"
>
<message-element
:class="$style.element"
:message-id="messageId"
:is-archived="isArchived"
@change-height="onChangeHeight"
@entry-message-loaded="onEntryMessageLoaded"
/>
</template>
</messages-scroller>
</transition>
<FormButton
label="メッセージを表示"
@click="
() => {
if (isMessageShow) {
isMessageShow = false
toNewMessage('smooth')
} else {
isMessageShow = true
nextTick(() => toNewMessage())
}
}
"
/>
<message-input
:channel-id="channelId"
:typing-users="typingUsers"
:show-to-new-message-button="showToNewMessageButton"
@click-to-new-message-button="toNewMessage"
/>
</div>
</template>

<script lang="ts" setup>
import MessagesScroller from '/@/components/Main/MainView/MessagesScroller/MessagesScroller.vue'
import MessageInput from '/@/components/Main/MainView/MessageInput/MessageInput.vue'
import ScrollLoadingBar from '/@/components/Main/MainView/ScrollLoadingBar.vue'
import { computed, nextTick, ref, shallowRef } from 'vue'
import type { ChannelId, UserId } from '/@/types/entity-ids'
import useChannelMessageFetcher from '../ChannelView/ChannelViewContent/composables/useChannelMessageFetcher'
import { useChannelsStore } from '/@/store/entities/channels'
import MessageElement from '/@/components/Main/MainView/MessageElement/MessageElement.vue'
import { useSubscriptionStore } from '/@/store/domain/subscription'
import FormButton from '/@/components/UI/FormButton.vue'

const props = defineProps<{
channelId: ChannelId
typingUsers: UserId[]
}>()

const isMessageShow = ref(false)

const scrollerEle = shallowRef<{ $el: HTMLDivElement } | undefined>()
const {
messageIds,
isReachedEnd,
isReachedLatest,
isLoading,
lastLoadingDirection,
onLoadFormerMessagesRequest,
onLoadLatterMessagesRequest
} = useChannelMessageFetcher(scrollerEle, props)

const { channelsMap } = useChannelsStore()
const isArchived = computed(
() => channelsMap.value.get(props.channelId)?.archived ?? false
)

const { unreadChannelsMap } = useSubscriptionStore()
const resetIsReachedLatest = () => {
if (!unreadChannelsMap.value.get(props.channelId)) return
isReachedLatest.value = false
}

const showToNewMessageButton = ref(false)
const toNewMessage = (behavior?: ScrollBehavior) => {
if (!scrollerEle.value) return
showToNewMessageButton.value = false
scrollerEle.value.$el.scrollTo({
top: scrollerEle.value.$el.scrollHeight,
behavior: behavior
})
}

const handleScroll = () => {
if (scrollerEle.value === undefined || isLoading.value) return
const { scrollTop, scrollHeight, clientHeight } = scrollerEle.value.$el
showToNewMessageButton.value = scrollHeight - 2 * clientHeight > scrollTop
if (!isReachedLatest.value) {
showToNewMessageButton.value = true
}
}
</script>

<style lang="scss" module>
.container {
display: flex;
flex: 1 1;
flex-direction: column;
justify-content: end;
position: relative;
height: 100%;
width: 100%;
}

.loadingBar {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 12px;
z-index: $z-index-message-loading;
}

.unreadSeparator {
color: $theme-accent-notification-default;
}

.dateSeparator {
@include color-ui-secondary;
}
.element {
margin: 4px 0;
contain: content;
}
</style>
14 changes: 14 additions & 0 deletions src/components/Main/MainView/QallView/QallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import CallControlButtonSmall from './CallControlButtonSmall.vue'
import ScreenShareComponent from './ScreenShareComponent.vue'
import { LocalTrackPublication } from 'livekit-client'
import ChannelViewContentMain from '../ChannelView/ChannelViewContent/ChannelViewContentMain.vue'

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

View workflow job for this annotation

GitHub Actions / run lint

'ChannelViewContentMain' is defined but never used
import QallMessageView from './QallMessageView.vue'

const {
tracksMap,
screenShareTrackSidMap,
callingChannel,
leaveQall,
addScreenShareTrack,
addCameraTrack,
Expand Down Expand Up @@ -59,7 +62,7 @@
}
}
} catch (err) {
console.error('Failed to toggle audio:', err)

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

View workflow job for this annotation

GitHub Actions / run lint

Unexpected console statement
}
}

Expand All @@ -86,7 +89,7 @@
? '/@/assets/icons/videocam.svg?url'
: '/@/assets/icons/videocam_off.svg?url'
} catch (err) {
console.error('Failed to toggle video:', err)

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

View workflow job for this annotation

GitHub Actions / run lint

Unexpected console statement
}
}

Expand All @@ -113,21 +116,21 @@
? '/@/assets/icons/stop_screen_share.svg?url'
: '/@/assets/icons/screen_share.svg?url'
} catch (err) {
console.error('Failed to toggle screen sharing:', err)

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

View workflow job for this annotation

GitHub Actions / run lint

Unexpected console statement
}
}

const handleSound = () => {
// TODO
console.log('sound')

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

View workflow job for this annotation

GitHub Actions / run lint

Unexpected console statement
}
const handleReaction = () => {
// TODO
console.log('reaction')

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

View workflow job for this annotation

GitHub Actions / run lint

Unexpected console statement
}
const handleGroup = () => {
// TODO
console.log('group')

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

View workflow job for this annotation

GitHub Actions / run lint

Unexpected console statement
}

const videoInputs = ref<MediaDeviceInfo[]>([])
Expand All @@ -145,6 +148,11 @@
<template>
<div :class="$style.Block">
<DanmakuContainer />
<QallMessageView
:channel-id="callingChannel"
:typing-users="[]"
:class="$style.channelView"
/>
<h1 :class="$style.Header">Qall View</h1>
{{ backgroundType }}
<button @click="addScreenShareTrack">Add Screen Share Track</button>
Expand Down Expand Up @@ -269,6 +277,12 @@
.TrackContainer {
height: fit-content;
}
.channelView {
position: absolute;
width: 30%;
right: 0;
bottom: 0;
}
.video {
width: 50%;
height: 50%;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Main/NavigationBar/DesktopNavigationBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/>
<transition name="fade-bottom">
<ephemeral-navigation-content
v-if="true"
v-if="ephemeralNavigationSelectorState.currentNavigation"
:class="$style.ephemeralNavigation"
:current-ephemeral-navigation="
ephemeralNavigationSelectorState.currentNavigation
Expand Down
Loading