Skip to content

Commit c07e15e

Browse files
committed
refactor: 空白を挿入して視認性を高める
1 parent e6a923d commit c07e15e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/store/domain/subscription.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,21 @@ const useSubscriptionStorePinia = defineStore('domain/subscription', () => {
4141
const unreadChannelsMap = ref(
4242
new Map<ChannelId | DMChannelId, UnreadChannel>()
4343
)
44+
4445
const unreadChannelsMapFetched = ref(false)
46+
4547
const unreadChannelsMapInitialFetchPromise = ref(
4648
useTrueChangedPromise(unreadChannelsMapFetched)
4749
)
50+
4851
const setUnreadChannelsMap = (
4952
newUnreadChannelsMap: Map<ChannelId, UnreadChannel>
5053
) => {
5154
unreadChannelsMap.value = newUnreadChannelsMap
5255
unreadChannelsMapFetched.value = true
5356
updateBadge(unreadChannelsMap.value)
5457
}
58+
5559
const upsertUnreadChannel = (
5660
message: Readonly<Message>,
5761
noticeable: boolean
@@ -77,6 +81,7 @@ const useSubscriptionStorePinia = defineStore('domain/subscription', () => {
7781
}
7882
updateBadge(unreadChannelsMap.value)
7983
}
84+
8085
/**
8186
* 既読になったイベントを受け取ったときに利用
8287
*/
@@ -85,6 +90,7 @@ const useSubscriptionStorePinia = defineStore('domain/subscription', () => {
8590
updateBadge(unreadChannelsMap.value)
8691
removeNotification(channelId)
8792
}
93+
8894
/**
8995
* 既読にするときに利用
9096
*/
@@ -102,6 +108,7 @@ const useSubscriptionStorePinia = defineStore('domain/subscription', () => {
102108
deleteUnreadChannel(channelId)
103109
}
104110
}
111+
105112
const fetchUnreadChannels = async ({
106113
ignoreCache = false
107114
}: { ignoreCache?: boolean } = {}) => {
@@ -117,6 +124,7 @@ const useSubscriptionStorePinia = defineStore('domain/subscription', () => {
117124

118125
const subscriptionMap = ref(new Map<ChannelId, ChannelSubscribeLevel>())
119126
const subscriptionMapFetched = ref(false)
127+
120128
const subscribedChannels = computed(
121129
() =>
122130
new Set(
@@ -129,9 +137,11 @@ const useSubscriptionStorePinia = defineStore('domain/subscription', () => {
129137
.map(([id]) => id)
130138
)
131139
)
140+
132141
const isChannelSubscribed = (channelId: ChannelId) =>
133142
(subscriptionMap.value.get(channelId) ?? ChannelSubscribeLevel.none) !==
134143
ChannelSubscribeLevel.none
144+
135145
const fetchSubscriptions = async ({
136146
ignoreCache = false
137147
}: { ignoreCache?: boolean } = {}) => {
@@ -152,10 +162,12 @@ const useSubscriptionStorePinia = defineStore('domain/subscription', () => {
152162
wsListener.on('MESSAGE_READ', ({ id }) => {
153163
deleteUnreadChannel(id)
154164
})
165+
155166
wsListener.on('reconnect', () => {
156167
fetchUnreadChannels({ ignoreCache: true })
157168
fetchSubscriptions({ ignoreCache: true })
158169
})
170+
159171
wsListener.on('CHANNEL_SUBSCRIBERS_CHANGED', () => {
160172
fetchSubscriptions({ ignoreCache: true })
161173
})

0 commit comments

Comments
 (0)