Skip to content

Commit

Permalink
Merge branch 'develop' into rav-128-setup-required-doctypes-for-creat…
Browse files Browse the repository at this point in the history
…ing-polls-on-raven
  • Loading branch information
nikkothari22 authored Apr 2, 2024
2 parents c7b0232 + ce47fce commit 8b6e4b8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mobile/src/components/features/chat-space/useChatStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,10 @@ const useChatStream = (channelID: string, scrollRef: RefObject<HTMLIonContentEle
name: messageDate
})
}
if (message.owner !== messages[i + 1].owner) {

const currentMessageSender = message.is_bot_message ? message.bot : message.owner
const nextMessageSender = messages[i + 1].is_bot_message ? messages[i + 1].bot : messages[i + 1].owner
if (currentMessageSender !== nextMessageSender) {
messagesWithDateSeparators.push({
...message,
is_continuation: 0
Expand Down
6 changes: 6 additions & 0 deletions mobile/src/utils/channel/ChannelListProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { KeyedMutator } from 'swr'
import { useIonToast } from '@ionic/react'
import { RavenChannel } from '../../../../types/RavenChannelManagement/RavenChannel'
import { UserContext } from '../auth/UserProvider'
import { useSWRConfig } from 'frappe-react-sdk'

export type ExtraUsersData = {
name: string,
Expand Down Expand Up @@ -73,6 +74,8 @@ const useFetchChannelList = (): ChannelListContextType => {
position: 'bottom',
});
};

const { mutate: globalMutate } = useSWRConfig()
const { data, mutate, ...rest } = useFrappeGetCall<{ message: ChannelList }>("raven.api.raven_channel.get_all_channels", {
hide_archived: false
}, isLoggedIn ? undefined : null, {
Expand All @@ -85,6 +88,9 @@ const useFetchChannelList = (): ChannelListContextType => {

useFrappeDocTypeEventListener('Raven Channel', () => {
mutate()

// Also update the unread channel count
globalMutate('unread_channel_count')
})

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ const useChatStream = (scrollRef: MutableRefObject<HTMLDivElement | null>) => {
})
}

if (message.owner !== messages[i + 1].owner) {
const currentMessageSender = message.is_bot_message ? message.bot : message.owner
const nextMessageSender = messages[i + 1].is_bot_message ? messages[i + 1].bot : messages[i + 1].owner

if (currentMessageSender !== nextMessageSender) {
messagesWithDateSeparators.push({
...message,
is_continuation: 0
Expand Down
5 changes: 5 additions & 0 deletions raven-app/src/utils/channel/ChannelListProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PropsWithChildren, createContext } from 'react'
import { KeyedMutator } from 'swr'
import { RavenChannel } from '../../../../types/RavenChannelManagement/RavenChannel'
import { useToast } from '@/hooks/useToast'
import { useSWRConfig } from 'frappe-react-sdk'

export type ExtraUsersData = {
name: string,
Expand Down Expand Up @@ -60,6 +61,7 @@ export const ChannelListProvider = ({ children }: PropsWithChildren) => {
export const useFetchChannelList = (): ChannelListContextType => {

const { toast } = useToast()
const { mutate: globalMutate } = useSWRConfig()
const { data, mutate, ...rest } = useFrappeGetCall<{ message: ChannelList }>("raven.api.raven_channel.get_all_channels", {
hide_archived: false
}, `channel_list`, {
Expand All @@ -75,6 +77,9 @@ export const useFetchChannelList = (): ChannelListContextType => {

useFrappeDocTypeEventListener('Raven Channel', () => {
mutate()

// Also update the unread channel count
globalMutate('unread_channel_count')
})

return {
Expand Down

0 comments on commit 8b6e4b8

Please sign in to comment.