-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] message content paging, 디자인 약간 수정 (#183)
- Loading branch information
Showing
12 changed files
with
432 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { unwrap } from '@/api/unwrap'; | ||
import { ApiContext } from '@/app/_internal/provider/ApiContext'; | ||
import { useCallback, useContext } from 'react'; | ||
import { useQueries } from 'react-query'; | ||
|
||
export default function useChannelMessage(channelId: string) { | ||
const { api } = useContext(ApiContext); | ||
const channelInfoFn = useCallback( | ||
async () => unwrap(await api.channelControllerFindChannelInfo(channelId)), | ||
[api, channelId], | ||
); | ||
const initialData = useCallback( | ||
async () => | ||
unwrap(await api.channelControllerGetChannelMessages(channelId)), | ||
[api, channelId], | ||
); | ||
const data = useQueries([ | ||
{ queryKey: 'channelInfo', queryFn: channelInfoFn }, | ||
{ queryKey: 'channelMessage', queryFn: initialData }, | ||
]); | ||
const isLoading = data.some((d: any) => d.isLoading); | ||
if (isLoading) return { isLoading: true }; | ||
|
||
const channelMessage: any = data[1].data; | ||
if (channelMessage.length > 0) { | ||
channelMessage.push({ | ||
type: 'scroll-target', | ||
}); | ||
} | ||
return { | ||
isLoading: isLoading, | ||
channelInfo: data[0].data, | ||
channelMessage, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { unwrap } from '@/api/unwrap'; | ||
import { ApiContext } from '@/app/_internal/provider/ApiContext'; | ||
import { useCallback, useContext } from 'react'; | ||
import { useQueries } from 'react-query'; | ||
|
||
export default function useDirectMessage( | ||
channelId: string, | ||
targetName: string, | ||
) { | ||
const { api } = useContext(ApiContext); | ||
const dmInfoFn = useCallback( | ||
async () => unwrap(await api.usersControllerGetUsetByNickname(targetName)), | ||
[api, targetName], | ||
); | ||
const initialData = useCallback( | ||
async () => unwrap(await api.dmControllerGetDmChannelMessages(targetName)), | ||
[api, targetName], | ||
); | ||
const data = useQueries([ | ||
{ queryKey: 'userByNickanme', queryFn: dmInfoFn }, | ||
{ queryKey: 'channelMessage', queryFn: initialData }, | ||
]); | ||
const isLoading = data.some((d: any) => d.isLoading); | ||
if (isLoading) return { isLoading: true }; | ||
const channelMessage: any = data[1].data; | ||
if (channelMessage.length > 0) { | ||
channelMessage.push({ | ||
type: 'scroll-target', | ||
}); | ||
} | ||
return { | ||
isLoading: isLoading, | ||
dmInfo: data[0].data, | ||
channelMessage, | ||
}; | ||
} |
Oops, something went wrong.