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

お気に入りチャンネルは未読で別に表示できるように #4321

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
19 changes: 15 additions & 4 deletions src/components/Main/NavigationBar/NavigationContent/HomeTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@
>
<channel-tree :channels="homeChannelWithTree" show-shortened-path />
</navigation-content-container>
<navigation-content-container
v-if="starredChannelsWithNotification.length !== 0"
subtitle="お気に入り"
:class="$style.item"
>
<channel-list :channels="starredChannelsWithNotification" />
</navigation-content-container>
<navigation-content-container
v-if="
dmChannelsWithNotification.length + channelsWithNotification.length !==
dmChannelsWithNotification.length +
notStarredChannelsWithNotification.length !==
0
"
subtitle="未読"
:class="$style.item"
>
<d-m-channel-list :dm-channels="dmChannelsWithNotification" />
<channel-list :channels="channelsWithNotification" />
<channel-list :channels="notStarredChannelsWithNotification" />
</navigation-content-container>
<navigation-content-container subtitle="チャンネル" :class="$style.item">
<channel-tree
Expand Down Expand Up @@ -66,8 +74,11 @@ const homeChannelWithTree = computed(() => {
return filterTrees(trees, channel => !channel.archived)
})

const { channelsWithNotification, dmChannelsWithNotification } =
useChannelsWithNotification()
const {
notStarredChannelsWithNotification,
starredChannelsWithNotification,
dmChannelsWithNotification
} = useChannelsWithNotification()

const topLevelChannels = computed(() =>
// filterTreesは重いのと内部ではreactiveである必要がないのでtoRawする
Expand Down
22 changes: 20 additions & 2 deletions src/composables/subscription/useChannelsWithNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { computed } from 'vue'
import { isDefined } from '/@/lib/basic/array'
import { useSubscriptionStore } from '/@/store/domain/subscription'
import { useChannelsStore } from '/@/store/entities/channels'
import { useStaredChannels } from '/@/store/domain/staredChannels'

const useChannelsWithNotification = () => {
const { unreadChannelsMap } = useSubscriptionStore()
const { channelsMap, dmChannelsMap } = useChannelsStore()
const starredChannelStore = useStaredChannels()

const sortedUnreadChannels = computed(() =>
[...unreadChannelsMap.value.values()].sort((a, b) => {
Expand All @@ -16,10 +18,22 @@ const useChannelsWithNotification = () => {
})
)

const channelsWithNotification = computed(() =>
const notStarredChannelsWithNotification = computed(() =>
sortedUnreadChannels.value
.map(unread => channelsMap.value.get(unread.channelId))
.filter(isDefined)
.filter(
channel => !starredChannelStore.staredChannelSet.value.has(channel.id)
)
)

const starredChannelsWithNotification = computed(() =>
sortedUnreadChannels.value
.map(unread => channelsMap.value.get(unread.channelId))
.filter(isDefined)
.filter(channel =>
starredChannelStore.staredChannelSet.value.has(channel.id)
)
cp-20 marked this conversation as resolved.
Show resolved Hide resolved
)

const dmChannelsWithNotification = computed(() =>
Expand All @@ -28,7 +42,11 @@ const useChannelsWithNotification = () => {
.filter(isDefined)
)

return { channelsWithNotification, dmChannelsWithNotification }
return {
notStarredChannelsWithNotification,
starredChannelsWithNotification,
dmChannelsWithNotification
}
}

export default useChannelsWithNotification
Loading