Skip to content

Commit

Permalink
Merge pull request #4468 from traPtitech/feat/qall_message_viewer
Browse files Browse the repository at this point in the history
メッセージビューワーの実装
  • Loading branch information
nokhnaton authored Jan 23, 2025
2 parents 1ab105e + 9f61d05 commit 0bd631d
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 2 deletions.
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"

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L2-L19

Added lines #L2 - L19 were not covered by tests
>
<template
#default="{ messageId, onChangeHeight, onEntryMessageLoaded }"

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L22 was not covered by tests
>
<message-element
:class="$style.element"
:message-id="messageId"
:is-archived="isArchived"
@change-height="onChangeHeight"
@entry-message-loaded="onEntryMessageLoaded"
/>

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L24-L30

Added lines #L24 - L30 were not covered by tests
</template>
</messages-scroller>
</transition>
<FormButton
label="メッセージを表示"
@click="

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L32-L36

Added lines #L32 - L36 were not covered by tests
() => {
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>

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L47-L54

Added lines #L47 - L54 were not covered by tests
</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'

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L58-L61

Added lines #L58 - L61 were not covered by tests
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'

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L63-L67

Added lines #L63 - L67 were not covered by tests
const props = defineProps<{

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L69

Added line #L69 was not covered by tests
channelId: ChannelId
typingUsers: UserId[]
}>()
const isMessageShow = ref(false)

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L74

Added line #L74 was not covered by tests
const scrollerEle = shallowRef<{ $el: HTMLDivElement } | undefined>()
const {
messageIds,
isReachedEnd,
isReachedLatest,
isLoading,
lastLoadingDirection,
onLoadFormerMessagesRequest,
onLoadLatterMessagesRequest
} = useChannelMessageFetcher(scrollerEle, props)

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L76-L85

Added lines #L76 - L85 were not covered by tests
const { channelsMap } = useChannelsStore()
const isArchived = computed(
() => channelsMap.value.get(props.channelId)?.archived ?? false
)

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L87-L90

Added lines #L87 - L90 were not covered by tests
const { unreadChannelsMap } = useSubscriptionStore()
const resetIsReachedLatest = () => {
if (!unreadChannelsMap.value.get(props.channelId)) return
isReachedLatest.value = false
}

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L92-L96

Added lines #L92 - L96 were not covered by tests
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
})
}

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L98-L106

Added lines #L98 - L106 were not covered by tests
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
}
}

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallMessageView.vue#L108-L115

Added lines #L108 - L115 were not covered by tests
</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 CallControlButton from './CallControlButton.vue'
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'

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallView.vue#L2-L12

Added lines #L2 - L12 were not covered by tests
const {
tracksMap,
screenShareTrackSidMap,
callingChannel,
leaveQall,
addScreenShareTrack,
addCameraTrack,
Expand Down Expand Up @@ -145,6 +148,11 @@ const backgroundType = ref<'original' | 'blur' | 'file' | 'screen'>('original')
<template>
<div :class="$style.Block">
<DanmakuContainer />
<QallMessageView
:channel-id="callingChannel"
:typing-users="[]"
:class="$style.channelView"
/>

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

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallView.vue#L150-L155

Added lines #L150 - L155 were not covered by tests
<h1 :class="$style.Header">Qall View</h1>
{{ backgroundType }}
<button @click="addScreenShareTrack">Add Screen Share Track</button>
Expand Down Expand Up @@ -269,6 +277,12 @@ const backgroundType = ref<'original' | 'blur' | 'file' | 'screen'>('original')
.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

0 comments on commit 0bd631d

Please sign in to comment.