-
Notifications
You must be signed in to change notification settings - Fork 2
feature/BA-2626-chatroom-list #293
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
Open
gabrieleandro
wants to merge
22
commits into
master
Choose a base branch
from
feature/BA-2626-rooms-list
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d853924
chatroom-list
gabrieleandro 777f74d
Merge remote-tracking branch 'origin/master' into feature/BA-2626-roo…
gabrieleandro ea2deaf
update-build-numbers
gabrieleandro 5b539eb
fix-comments
gabrieleandro c97b67f
fix-comments-2
gabrieleandro 8082214
fix-comments-3
gabrieleandro bda134d
fix-comment
gabrieleandro 36dd6d9
fix-comment-2
gabrieleandro 8a10cfd
fix-comments
gabrieleandro 5ad95fd
upgrade flash-list and update roomlistComponent
gabrieleandro 8066360
Merge remote-tracking branch 'origin/master' into feature/BA-2626-roo…
gabrieleandro 6f0828e
fix-comments
gabrieleandro ca23e2f
fix-comments
gabrieleandro 07e30ce
update luxon version
gabrieleandro b5768a1
fix-comments
gabrieleandro c66ae22
fix-comments
gabrieleandro fac96cd
fix-comments
gabrieleandro 1967742
fix-comments
gabrieleandro 05ad890
fix-buld-issue
gabrieleandro 763e0cd
Merge remote-tracking branch 'origin/master' into feature/BA-2626-roo…
gabrieleandro c1c2c06
update-changelog
gabrieleandro 18dafea
add-profileId
gabrieleandro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
29 changes: 29 additions & 0 deletions
29
packages/components/modules/__shared__/native/EmptyView/index.tsx
This file contains hidden or 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,29 @@ | ||
| import { Text } from '@baseapp-frontend/design-system/components/native/typographies' | ||
| import { View } from '@baseapp-frontend/design-system/components/native/views' | ||
| import { useTheme } from '@baseapp-frontend/design-system/providers/native' | ||
|
|
||
| import { createStyles } from './styles' | ||
| import { EmptyViewProps } from './types' | ||
|
|
||
| const EmptyView = ({ icon, title, message, style }: EmptyViewProps) => { | ||
| const theme = useTheme() | ||
| const styles = createStyles(theme) | ||
|
|
||
| return ( | ||
| <View style={[styles.container, style]}> | ||
| {icon && <View style={styles.imageWrapper}>{icon}</View>} | ||
| <View style={styles.textWrapper}> | ||
| <Text variant="subtitle2" style={styles.text}> | ||
| {title} | ||
| </Text> | ||
| {message && ( | ||
| <Text variant="caption" style={styles.text}> | ||
| {message} | ||
| </Text> | ||
| )} | ||
| </View> | ||
| </View> | ||
| ) | ||
| } | ||
|
|
||
| export default EmptyView |
30 changes: 30 additions & 0 deletions
30
packages/components/modules/__shared__/native/EmptyView/styles.ts
This file contains hidden or 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,30 @@ | ||
| import { Theme } from '@baseapp-frontend/design-system/styles/native' | ||
|
|
||
| import { StyleSheet } from 'react-native' | ||
|
|
||
| export const createStyles = (theme: Theme) => | ||
| StyleSheet.create({ | ||
| container: { | ||
| flex: 1, | ||
| padding: 32, | ||
| flexDirection: 'column', | ||
| gap: 12, | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| }, | ||
| imageWrapper: { | ||
| flex: 1, | ||
| alignItems: 'center', | ||
| }, | ||
| textWrapper: { | ||
| flex: 1, | ||
| maxWidth: '100%', | ||
| padding: 16, | ||
| justifyContent: 'flex-end', | ||
| alignItems: 'center', | ||
| gap: 10, | ||
| }, | ||
| text: { | ||
| color: theme.colors.object.low, | ||
| }, | ||
| }) |
10 changes: 10 additions & 0 deletions
10
packages/components/modules/__shared__/native/EmptyView/types.ts
This file contains hidden or 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,10 @@ | ||
| import { ReactNode } from 'react' | ||
|
|
||
| import { StyleProp, ViewStyle } from 'react-native' | ||
|
|
||
| export interface EmptyViewProps { | ||
| icon?: ReactNode | ||
| title: string | ||
| message?: string | ||
| style?: StyleProp<ViewStyle> | ||
| } |
This file contains hidden or 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,2 @@ | ||
| export { default as EmptyView } from './EmptyView' | ||
| export type * from './EmptyView/types' |
16 changes: 16 additions & 0 deletions
16
packages/components/modules/messages/common/graphql/fragments/ChatRoom.ts
This file contains hidden or 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,16 @@ | ||
| import { graphql } from 'react-relay' | ||
|
|
||
| export const ChatRoomFragment = graphql` | ||
| fragment ChatRoomFragment on ChatRoom @refetchable(queryName: "ChatRoomFragmentRefetchQuery") { | ||
| id | ||
| isGroup | ||
| isArchived | ||
| unreadMessages { | ||
| count | ||
| markedUnread | ||
| } | ||
| participantsCount | ||
| ...TitleFragment | ||
| ...MessagesListFragment | ||
| } | ||
| ` |
This file contains hidden or 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
139 changes: 139 additions & 0 deletions
139
packages/components/modules/messages/native/ChatRooms/index.tsx
This file contains hidden or 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,139 @@ | ||
| import { FC, Suspense, useState, useTransition } from 'react' | ||
|
|
||
| import { useCurrentProfile } from '@baseapp-frontend/authentication' | ||
| import { LoadingScreen } from '@baseapp-frontend/design-system/components/native/displays' | ||
| import { | ||
| DEFAULT_FORM_VALUES, | ||
| FORM_VALUES, | ||
| SearchInput, | ||
| SearchInputFormValues, | ||
| } from '@baseapp-frontend/design-system/components/native/inputs' | ||
| import { Tab, Tabs } from '@baseapp-frontend/design-system/components/native/tabs' | ||
| import { Text } from '@baseapp-frontend/design-system/components/native/typographies' | ||
| import { PageViewWithHeader, View } from '@baseapp-frontend/design-system/components/native/views' | ||
| import { useTheme } from '@baseapp-frontend/design-system/providers/native' | ||
| import { useAppStateSubscription } from '@baseapp-frontend/utils/hooks/useAppStateSubscription' | ||
|
|
||
| import { useForm } from 'react-hook-form' | ||
| import { useLazyLoadQuery, useRelayEnvironment } from 'react-relay' | ||
|
|
||
| import { ChatRoomsQuery as ChatRoomsQueryType } from '../../../../__generated__/ChatRoomsQuery.graphql' | ||
| import { RoomsListFragment$key } from '../../../../__generated__/RoomsListFragment.graphql' | ||
| import { useRoomsList } from '../../common' | ||
| import { ChatRoomsQuery } from '../../common/graphql/queries/ChatRoomsQuery' | ||
| import { NewChatButton } from '../NewChatButton' | ||
| import RoomsList from '../RoomsList' | ||
| import { CHAT_TAB_LABEL, CHAT_TAB_VALUES } from '../RoomsList/RoomsListComponent/constants' | ||
| import { ChatTabValues } from '../RoomsList/RoomsListComponent/types' | ||
| import { useRoomListSubscription } from '../graphql/subscriptions/useRoomListSubscription' | ||
| import { createStyles } from './styles' | ||
|
|
||
| const ChatRooms: FC = () => { | ||
| const theme = useTheme() | ||
| const styles = createStyles(theme) | ||
| const { control, watch, setValue, reset } = useForm<SearchInputFormValues>({ | ||
| defaultValues: DEFAULT_FORM_VALUES, | ||
| }) | ||
| const searchParam = watch(FORM_VALUES.search) | ||
| const [selectedTab, setSelectedTab] = useState<string>(CHAT_TAB_VALUES.active) | ||
| const [, startTransition] = useTransition() | ||
| const { currentProfile } = useCurrentProfile() | ||
| const chatRoomQueryData = useLazyLoadQuery<ChatRoomsQueryType>( | ||
| ChatRoomsQuery, | ||
| { profileId: currentProfile?.id || '' }, | ||
| { fetchPolicy: 'store-and-network' }, | ||
| ) | ||
| const { data, refetch } = useRoomsList(chatRoomQueryData?.profile as RoomsListFragment$key) | ||
|
|
||
| const handleSearchChange = (text: string) => { | ||
| startTransition(() => { | ||
| setValue(FORM_VALUES.search, text) | ||
| }) | ||
| } | ||
|
|
||
| const resetInput = () => { | ||
| setValue(FORM_VALUES.search, DEFAULT_FORM_VALUES.search) | ||
| reset(DEFAULT_FORM_VALUES) | ||
| } | ||
|
|
||
| const environment = useRelayEnvironment() | ||
| useRoomListSubscription({ profileId: data?.id, connections: [], environment }) | ||
|
|
||
| const handleChange = (newValue: string) => { | ||
| setSelectedTab(newValue as ChatTabValues) | ||
| } | ||
|
|
||
| useAppStateSubscription(() => { | ||
| refetch( | ||
| { | ||
| q: searchParam, | ||
| unreadMessages: selectedTab === CHAT_TAB_VALUES.unread, | ||
| archived: selectedTab === CHAT_TAB_VALUES.archived, | ||
| }, | ||
| { fetchPolicy: 'store-and-network' }, | ||
| ) | ||
| }) | ||
|
|
||
| return ( | ||
| <PageViewWithHeader> | ||
| <View style={styles.container}> | ||
| <Text variant="h4">Messages</Text> | ||
| <SearchInput | ||
| placeholder="Search" | ||
| onChangeText={handleSearchChange} | ||
| control={control} | ||
| name={FORM_VALUES.search} | ||
| searchParam={searchParam} | ||
| resetInput={resetInput} | ||
| autoComplete="off" | ||
| autoCorrect={false} | ||
| /> | ||
|
|
||
| <Tabs value={selectedTab} onChange={handleChange} style={styles.tabs}> | ||
| <Tab | ||
| label={CHAT_TAB_LABEL.active} | ||
| value={CHAT_TAB_VALUES.active} | ||
| aria-label="Active messages tab" | ||
| /> | ||
| <Tab | ||
| label={CHAT_TAB_LABEL.unread} | ||
| value={CHAT_TAB_VALUES.unread} | ||
| aria-label="Unread messages tab" | ||
| /> | ||
| <Tab | ||
| label={CHAT_TAB_LABEL.archived} | ||
| value={CHAT_TAB_VALUES.archived} | ||
| aria-label="Archived messages tab" | ||
| /> | ||
| </Tabs> | ||
| { | ||
| // TODO: Handle groups tab separately will be implemented later | ||
|
Check warning on line 110 in packages/components/modules/messages/native/ChatRooms/index.tsx
|
||
| selectedTab === CHAT_TAB_VALUES.groups ? ( | ||
| <Text>Groups tab is not implemented yet.</Text> | ||
| ) : ( | ||
| <RoomsList | ||
| targetRef={chatRoomQueryData} | ||
| searchParam={searchParam} | ||
| selectedTab={selectedTab} | ||
| /> | ||
| ) | ||
| } | ||
| <NewChatButton /> | ||
| </View> | ||
| </PageViewWithHeader> | ||
| ) | ||
| } | ||
|
|
||
| const SuspendedChatRooms = () => ( | ||
| <Suspense | ||
| fallback={ | ||
| <View style={{ flex: 1 }}> | ||
| <LoadingScreen /> | ||
| </View> | ||
| } | ||
| > | ||
| <ChatRooms /> | ||
| </Suspense> | ||
| ) | ||
|
|
||
| export default SuspendedChatRooms | ||
20 changes: 20 additions & 0 deletions
20
packages/components/modules/messages/native/ChatRooms/styles.ts
This file contains hidden or 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,20 @@ | ||
| import { Theme } from '@baseapp-frontend/design-system/styles/native' | ||
|
|
||
| import { StyleSheet } from 'react-native' | ||
|
|
||
| export const createStyles = (theme: Theme) => | ||
| StyleSheet.create({ | ||
| container: { | ||
| backgroundColor: theme.colors.surface.background, | ||
| flexGrow: 1, | ||
| flex: 1, | ||
| position: 'relative', | ||
| }, | ||
| chatRoomsContainer: { | ||
| flexGrow: 1, | ||
| }, | ||
| tabs: { | ||
| justifyContent: 'space-evenly', | ||
| gap: 0, | ||
| }, | ||
| }) |
24 changes: 24 additions & 0 deletions
24
packages/components/modules/messages/native/NewChatButton/index.tsx
This file contains hidden or 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,24 @@ | ||
| import React from 'react' | ||
|
|
||
| import { FabButton } from '@baseapp-frontend/design-system/components/native/buttons' | ||
| import { useTheme } from '@baseapp-frontend/design-system/providers/native' | ||
|
|
||
| import { useRouter } from 'expo-router' | ||
|
|
||
| const NewChatButton = () => { | ||
| const theme = useTheme() | ||
| const router = useRouter() | ||
|
|
||
| const navigateToCreateRoom = () => router.push('/create-room') | ||
|
|
||
| return ( | ||
| <FabButton | ||
| onPress={navigateToCreateRoom} | ||
| iconName="add" | ||
| iconSize={28} | ||
| iconColor={theme.colors.primary.contrast} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export { NewChatButton } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 149
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 377
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 730
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 139
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 5808
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 166
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 233
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 54
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 479
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 1403
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 593
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 99
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 7115
🏁 Script executed:
Repository: silverlogic/baseapp-frontend
Length of output: 903
The empty string fallback for
profileIdviolates the GraphQL schema contract and causes runtime errors.The GraphQL query requires
profileId: ID!(non-nullable ID), but passing an empty string whencurrentProfileis null is not a valid ID value. SincecurrentProfilecan be null (defined inCurrentProfileStateasMinimalProfile | null), this will causeuseLazyLoadQueryto fail when executed without proper validation.Recommended fix: Guard the component to only render when
currentProfile?.idexists, or conditionally skip the query execution until the profile ID is available.🤖 Prompt for AI Agents