Skip to content

Commit 3b7b8b4

Browse files
authored
Merge pull request #4395 from traPtitech/feat/transparent_inactive_user
traQにフォーカスしてないユーザーの表示を変更する。
2 parents 81fb1fc + 53be2d6 commit 3b7b8b4

File tree

16 files changed

+208
-70
lines changed

16 files changed

+208
-70
lines changed

src/components/Main/MainView/ChannelView/ChannelSidebar/ChannelSidebar.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<channel-sidebar-content
1010
v-model:is-viewers-detail-open="isViewersDetailOpen"
1111
:channel-id="channelId"
12-
:viewer-ids="viewingUsers"
12+
:viewer-ids="activeViewingUsers"
13+
:inactive-viewer-ids="inactiveViewingUsers"
1314
:pinned-messages-count="pinnedMessages.length"
1415
@move-to-pinned="moveToPinnedPage"
1516
@move-to-events="moveToEventsPage"
@@ -29,7 +30,8 @@
2930
</template>
3031
<template #opener>
3132
<channel-sidebar-hidden
32-
:viewer-ids="viewingUsers"
33+
:viewer-ids="activeViewingUsers"
34+
:inactive-viewer-ids="inactiveViewingUsers"
3335
@open="openSidebar"
3436
@open-viewers="openViewers"
3537
/>
@@ -56,7 +58,8 @@ const props = defineProps<{
5658
channelId: ChannelId
5759
isSidebarOpenerReady: boolean
5860
pinnedMessages: Pin[]
59-
viewingUsers: UserId[]
61+
activeViewingUsers: UserId[]
62+
inactiveViewingUsers: UserId[]
6063
}>()
6164
6265
const { channelsMap } = useChannelsStore()

src/components/Main/MainView/ChannelView/ChannelSidebar/ChannelSidebarContent.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<channel-sidebar-viewers
44
v-model="isViewersDetailOpen"
55
:viewer-ids="viewerIds"
6+
:inactive-viewer-ids="inactiveViewerIds"
67
:class="$style.sidebarItem"
78
/>
89
<channel-sidebar-qall
@@ -57,6 +58,7 @@ const props = withDefaults(
5758
defineProps<{
5859
channelId: ChannelId
5960
viewerIds: readonly UserId[]
61+
inactiveViewerIds: readonly UserId[]
6062
pinnedMessagesCount?: number
6163
isViewersDetailOpen: boolean
6264
}>(),

src/components/Main/MainView/ChannelView/ChannelSidebar/ChannelSidebarHidden.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
count-clickable
1414
show-count
1515
:user-ids="viewerIds"
16+
:inactive-user-ids="inactiveViewerIds"
1617
:class="$style.rest"
1718
@count-click="emit('openViewers')"
1819
/>
@@ -27,6 +28,7 @@ import type { UserId } from '/@/types/entity-ids'
2728
withDefaults(
2829
defineProps<{
2930
viewerIds?: readonly UserId[]
31+
inactiveViewerIds?: readonly UserId[]
3032
}>(),
3133
{
3234
viewerIds: () => []

src/components/Main/MainView/ChannelView/ChannelSidebar/ChannelSidebarViewers.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
direction="row"
1010
transition="fade-right"
1111
:user-ids="viewerIds"
12+
:inactive-user-ids="inactiveViewerIds"
1213
@toggle="toggle"
1314
/>
1415
</sidebar-content-container>
1516
<channel-sidebar-viewers-detail
1617
v-else
1718
:viewer-ids="viewerIds"
19+
:inactive-viewer-ids="inactiveViewerIds"
1820
@toggle="toggle"
1921
/>
2022
</template>
@@ -31,6 +33,7 @@ import { useModelValueSyncer } from '/@/composables/useModelSyncer'
3133
const props = withDefaults(
3234
defineProps<{
3335
viewerIds?: readonly UserId[]
36+
inactiveViewerIds?: readonly UserId[]
3437
modelValue: boolean
3538
}>(),
3639
{

src/components/Main/MainView/ChannelView/ChannelSidebar/ChannelSidebarViewersDetail.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template>
22
<sidebar-content-container clickable title="閲覧者" @toggle="emit('toggle')">
3-
<div v-for="user in users" :key="user.id" :class="$style.item">
3+
<div v-for="user in viewers" :key="user.id" :class="$style.item">
4+
<user-icon :user-id="user.id" :size="32" />
5+
<div :class="$style.userName">{{ user.displayName }}</div>
6+
</div>
7+
<div
8+
v-for="user in inactiveUsers"
9+
:key="user.id"
10+
:class="[$style.item, $style.transparent]"
11+
>
412
<user-icon :user-id="user.id" :size="32" />
513
<div :class="$style.userName">{{ user.displayName }}</div>
614
</div>
@@ -18,9 +26,11 @@ import { useUsersStore } from '/@/store/entities/users'
1826
const props = withDefaults(
1927
defineProps<{
2028
viewerIds?: readonly UserId[]
29+
inactiveViewerIds?: readonly UserId[]
2130
}>(),
2231
{
23-
viewerIds: () => []
32+
viewerIds: () => [],
33+
inactiveViewerIds: () => []
2434
}
2535
)
2636
@@ -29,9 +39,12 @@ const emit = defineEmits<{
2939
}>()
3040
3141
const { usersMap } = useUsersStore()
32-
const users = computed(() =>
42+
const viewers = computed(() =>
3343
props.viewerIds.map(id => usersMap.value.get(id)).filter(isDefined)
3444
)
45+
const inactiveUsers = computed(() =>
46+
props.inactiveViewerIds.map(id => usersMap.value.get(id)).filter(isDefined)
47+
)
3548
</script>
3649

3750
<style lang="scss" module>
@@ -46,6 +59,9 @@ const users = computed(() =>
4659
margin-bottom: 0;
4760
}
4861
}
62+
.transparent {
63+
opacity: 0.5;
64+
}
4965
.userName {
5066
margin-left: 8px;
5167
font-weight: bold;

src/components/Main/MainView/ChannelView/ChannelView.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
:channel-id="channelId"
2020
:is-sidebar-opener-ready="isReady"
2121
:pinned-messages="pinnedMessages"
22-
:viewing-users="viewingUsers"
22+
:active-viewing-users="activeViewingUsers"
23+
:inactive-viewing-users="inactiveViewingUsers"
2324
/>
2425
</template>
2526
</primary-view-frame>
@@ -45,6 +46,8 @@ const props = defineProps<{
4546
4647
const channelId = toRef(props, 'channelId')
4748
const pinnedMessages = usePinnedMessages(channelId)
48-
const { viewingUsers, typingUsers } = useCurrentViewers(channelId)
49+
50+
const { activeViewingUsers, inactiveViewingUsers, typingUsers } =
51+
useCurrentViewers(channelId)
4952
const { getQallingState } = useQall()
5053
</script>

src/components/Main/MainView/ChannelView/ChannelViewContent/ChannelViewContentMain.vue

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@request-load-former="onLoadFormerMessagesRequest"
1313
@request-load-latter="onLoadLatterMessagesRequest"
1414
@scroll-passive="handleScroll"
15-
@reset-is-reached-latest="resetIsReachedLatest"
15+
@window-viewed="onWindowViewed"
1616
>
1717
<template #default="{ messageId, onChangeHeight, onEntryMessageLoaded }">
1818
<messages-scroller-separator
@@ -46,23 +46,23 @@
4646
</template>
4747

4848
<script lang="ts" setup>
49-
import MessagesScroller from '/@/components/Main/MainView/MessagesScroller/MessagesScroller.vue'
50-
import MessageInput from '/@/components/Main/MainView/MessageInput/MessageInput.vue'
51-
import ScrollLoadingBar from '/@/components/Main/MainView/ScrollLoadingBar.vue'
49+
import type { Pin } from '@traptitech/traq'
5250
import { computed, ref, shallowRef } from 'vue'
53-
import type { ChannelId, MessageId, UserId } from '/@/types/entity-ids'
51+
import { useRouter } from 'vue-router'
5452
import useChannelMessageFetcher from './composables/useChannelMessageFetcher'
55-
import { useChannelsStore } from '/@/store/entities/channels'
53+
import useDayDiffMessages from './composables/useDayDiffMessages'
5654
import MessageElement from '/@/components/Main/MainView/MessageElement/MessageElement.vue'
55+
import MessageInput from '/@/components/Main/MainView/MessageInput/MessageInput.vue'
56+
import MessagesScroller from '/@/components/Main/MainView/MessagesScroller/MessagesScroller.vue'
5757
import MessagesScrollerSeparator from '/@/components/Main/MainView/MessagesScroller/MessagesScrollerSeparator.vue'
58-
import { useMessagesStore } from '/@/store/entities/messages'
59-
import useDayDiffMessages from './composables/useDayDiffMessages'
58+
import ScrollLoadingBar from '/@/components/Main/MainView/ScrollLoadingBar.vue'
59+
import useChannelPath from '/@/composables/useChannelPath'
6060
import { getFullDayString } from '/@/lib/basic/date'
61-
import type { Pin } from '@traptitech/traq'
62-
import { useRouter } from 'vue-router'
6361
import { constructChannelPath } from '/@/router'
64-
import useChannelPath from '/@/composables/useChannelPath'
6562
import { useSubscriptionStore } from '/@/store/domain/subscription'
63+
import { useChannelsStore } from '/@/store/entities/channels'
64+
import { useMessagesStore } from '/@/store/entities/messages'
65+
import type { ChannelId, MessageId, UserId } from '/@/types/entity-ids'
6666
6767
const props = defineProps<{
6868
channelId: ChannelId
@@ -86,6 +86,9 @@ const {
8686
onLoadAroundMessagesRequest
8787
} = useChannelMessageFetcher(scrollerEle, props)
8888
89+
const { unreadChannelsMap, deleteUnreadChannelWithSend } =
90+
useSubscriptionStore()
91+
8992
const { messagesMap } = useMessagesStore()
9093
const firstUnreadMessageId = computed(() => {
9194
if (!unreadSince.value) return ''
@@ -114,9 +117,17 @@ const messagePinnedUserMap = computed(
114117
() => new Map(props.pinnedMessages.map(pin => [pin.message.id, pin.userId]))
115118
)
116119
117-
const { unreadChannelsMap } = useSubscriptionStore()
118-
const resetIsReachedLatest = () => {
119-
if (!unreadChannelsMap.value.get(props.channelId)) return
120+
const onWindowViewed = () => {
121+
const unread = unreadChannelsMap.value.get(props.channelId)
122+
if (unread === undefined) return
123+
//最後まで読み込まれている時は「ここから未読」の位置を修正し、未読を消す。
124+
if (
125+
unread.updatedAt ===
126+
messagesMap.value.get(messageIds.value.at(-1) ?? '')?.createdAt
127+
) {
128+
unreadSince.value = unread.since
129+
deleteUnreadChannelWithSend(props.channelId)
130+
}
120131
isReachedLatest.value = false
121132
}
122133

src/components/Main/MainView/DMView/DMSidebar/DMSidebar.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
</template>
88
<template #content>
99
<sidebar-content
10-
:viewer-ids="viewingUsers"
10+
:viewer-ids="activeViewingUsers"
11+
:inactive-viewer-ids="inactiveViewingUsers"
1112
:pinned-messages-count="pinnedMessages.length"
1213
@move-to-pinned="moveToPinnedPage"
1314
@move-to-events="moveToEventsPage"
@@ -26,7 +27,11 @@
2627
/>
2728
</template>
2829
<template #opener>
29-
<channel-sidebar-hidden :viewer-ids="viewingUsers" @open="openSidebar" />
30+
<channel-sidebar-hidden
31+
:viewer-ids="activeViewingUsers"
32+
:inactive-viewer-ids="inactiveViewingUsers"
33+
@open="openSidebar"
34+
/>
3035
</template>
3136
</primary-view-sidebar>
3237
</template>
@@ -48,7 +53,8 @@ defineProps<{
4853
userName: string
4954
isSidebarOpenerReady: boolean
5055
pinnedMessages: Pin[]
51-
viewingUsers: UserId[]
56+
activeViewingUsers: UserId[]
57+
inactiveViewingUsers: UserId[]
5258
}>()
5359
5460
const {

src/components/Main/MainView/DMView/DMSidebar/DMSidebarContent.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<channel-sidebar-viewers
44
v-model="isViewersDetailOpen"
55
:viewer-ids="viewerIds"
6+
:inactive-viewer-ids="inactiveViewerIds"
67
:class="$style.item"
78
/>
89
<channel-sidebar-pinned
@@ -27,6 +28,7 @@ import { ref } from 'vue'
2728
withDefaults(
2829
defineProps<{
2930
viewerIds: readonly UserId[]
31+
inactiveViewerIds?: readonly UserId[]
3032
pinnedMessagesCount?: number
3133
}>(),
3234
{

src/components/Main/MainView/DMView/DMView.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
:user-name="userName"
1818
:is-sidebar-opener-ready="isReady"
1919
:pinned-messages="pinnedMessages"
20-
:viewing-users="viewingUsers"
20+
:active-viewing-users="activeViewingUsers"
21+
:inactive-viewing-users="inactiveViewingUsers"
2122
/>
2223
</template>
2324
</primary-view-frame>
@@ -42,5 +43,6 @@ const props = defineProps<{
4243
4344
const channelId = toRef(props, 'channelId')
4445
const pinnedMessages = usePinnedMessages(channelId)
45-
const { viewingUsers, typingUsers } = useCurrentViewers(channelId)
46+
const { activeViewingUsers, inactiveViewingUsers, typingUsers } =
47+
useCurrentViewers(channelId)
4648
</script>

0 commit comments

Comments
 (0)