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

Extra keyboard #8348

Merged
merged 7 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add missing providers to involved screens
  • Loading branch information
enahum committed Nov 14, 2024
commit e27050b8e9faefdd0c25c46687bc2a820e36864f
9 changes: 7 additions & 2 deletions app/context/extra_keyboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ export const ExtraKeyboardProvider = (({children}: {children: React.ReactElement
export const useExtraKeyboardContext = (): ExtraKeyboardContextProps|undefined => {
const context = useContext(ExtraKeyboardContext);
if (!context) {
// commented until we add the provider surrounding the code where we call this function
// throw new Error('useExtraKeyboardContext must be used within a ExtraKeyboardProvider');
throw new Error('useExtraKeyboardContext must be used within a ExtraKeyboardProvider');
}
return context;
};
Expand All @@ -93,6 +92,12 @@ export const useHideExtraKeyboardIfNeeded = (callback: (...args: any) => void, d
if (keyboardContext?.isExtraKeyboardVisible) {
keyboardContext.hideExtraKeyboard();

/*
/* At this point the early return is commented
/* Based on the UX we actually want to have
/* we can uncoment this and reaturn as early
/* as the custom keyboard is hidden
*/
// return;
}

Expand Down
5 changes: 3 additions & 2 deletions app/screens/home/recent_mentions/recent_mentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import DateSeparator from '@components/post_list/date_separator';
import PostWithChannelInfo from '@components/post_with_channel_info';
import RoundedHeaderContext from '@components/rounded_header_context';
import {Events, Screens} from '@constants';
import {ExtraKeyboardProvider} from '@context/extra_keyboard';
import {useServerUrl} from '@context/server';
import {useTheme} from '@context/theme';
import {useCollapsibleHeader} from '@hooks/header';
Expand Down Expand Up @@ -162,7 +163,7 @@ const RecentMentionsScreen = ({appsEnabled, customEmojiNames, mentions, currentT
}, [appsEnabled, customEmojiNames]);

return (
<>
<ExtraKeyboardProvider>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
Expand Down Expand Up @@ -200,7 +201,7 @@ const RecentMentionsScreen = ({appsEnabled, customEmojiNames, mentions, currentT
/>
</Animated.View>
</SafeAreaView>
</>
</ExtraKeyboardProvider>
);
};

Expand Down
5 changes: 3 additions & 2 deletions app/screens/home/saved_messages/saved_messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import DateSeparator from '@components/post_list/date_separator';
import PostWithChannelInfo from '@components/post_with_channel_info';
import RoundedHeaderContext from '@components/rounded_header_context';
import {Events, Screens} from '@constants';
import {ExtraKeyboardProvider} from '@context/extra_keyboard';
import {useServerUrl} from '@context/server';
import {useTheme} from '@context/theme';
import {useCollapsibleHeader} from '@hooks/header';
Expand Down Expand Up @@ -164,7 +165,7 @@ function SavedMessages({appsEnabled, posts, currentTimezone, customEmojiNames}:
}, [appsEnabled, currentTimezone, customEmojiNames, theme]);

return (
<>
<ExtraKeyboardProvider>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
Expand Down Expand Up @@ -202,7 +203,7 @@ function SavedMessages({appsEnabled, posts, currentTimezone, customEmojiNames}:
/>
</Animated.View>
</SafeAreaView>
</>
</ExtraKeyboardProvider>
);
}

Expand Down
57 changes: 30 additions & 27 deletions app/screens/home/search/results/post_results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import NoResultsWithTerm from '@components/no_results_with_term';
import DateSeparator from '@components/post_list/date_separator';
import PostWithChannelInfo from '@components/post_with_channel_info';
import {Screens} from '@constants';
import {ExtraKeyboardProvider} from '@context/extra_keyboard';
import {useTheme} from '@context/theme';
import {convertSearchTermToRegex, parseSearchTerms} from '@utils/markdown';
import {getDateForDateLine, selectOrderedPosts} from '@utils/post_list';
Expand Down Expand Up @@ -89,7 +90,7 @@ const PostResults = ({
default:
return null;
}
}, [appsEnabled, customEmojiNames, searchValue, matches]);
}, [currentTimezone, searchValue, matches, appsEnabled, customEmojiNames]);

const noResults = useMemo(() => (
<NoResultsWithTerm
Expand All @@ -99,33 +100,35 @@ const PostResults = ({
), [searchValue]);

return (
<FlatList
ListHeaderComponent={
<FormattedText
style={styles.resultsNumber}
id='mobile.search.results'
defaultMessage='{count} search {count, plural, one {result} other {results}}'
values={{count: posts.length}}
/>
}
ListEmptyComponent={noResults}
contentContainerStyle={containerStyle}
data={orderedPosts}
indicatorStyle='black'
initialNumToRender={5}
<ExtraKeyboardProvider>
<FlatList
ListHeaderComponent={
<FormattedText
style={styles.resultsNumber}
id='mobile.search.results'
defaultMessage='{count} search {count, plural, one {result} other {results}}'
values={{count: posts.length}}
/>
}
ListEmptyComponent={noResults}
contentContainerStyle={containerStyle}
data={orderedPosts}
indicatorStyle='black'
initialNumToRender={5}

//@ts-expect-error key not defined in types
listKey={'posts'}
maxToRenderPerBatch={5}
nestedScrollEnabled={true}
refreshing={false}
removeClippedSubviews={true}
renderItem={renderItem}
scrollEventThrottle={16}
scrollToOverflowEnabled={true}
showsVerticalScrollIndicator={true}
testID='search_results.post_list.flat_list'
/>
//@ts-expect-error key not defined in types
listKey={'posts'}
maxToRenderPerBatch={5}
nestedScrollEnabled={true}
refreshing={false}
removeClippedSubviews={true}
renderItem={renderItem}
scrollEventThrottle={16}
scrollToOverflowEnabled={true}
showsVerticalScrollIndicator={true}
testID='search_results.post_list.flat_list'
/>
</ExtraKeyboardProvider>
);
};

Expand Down
25 changes: 14 additions & 11 deletions app/screens/pinned_messages/pinned_messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Loading from '@components/loading';
import DateSeparator from '@components/post_list/date_separator';
import Post from '@components/post_list/post';
import {Events, Screens} from '@constants';
import {ExtraKeyboardProvider} from '@context/extra_keyboard';
import {useServerUrl} from '@context/server';
import {useTheme} from '@context/theme';
import useAndroidHardwareBackHandler from '@hooks/android_back_handler';
Expand Down Expand Up @@ -152,17 +153,19 @@ function SavedMessages({
style={styles.flex}
testID='pinned_messages.screen'
>
<FlatList
contentContainerStyle={data.length ? styles.list : [styles.empty]}
ListEmptyComponent={emptyList}
data={data}
onRefresh={handleRefresh}
refreshing={refreshing}
renderItem={renderItem}
scrollToOverflowEnabled={true}
onViewableItemsChanged={onViewableItemsChanged}
testID='pinned_messages.post_list.flat_list'
/>
<ExtraKeyboardProvider>
<FlatList
contentContainerStyle={data.length ? styles.list : [styles.empty]}
ListEmptyComponent={emptyList}
data={data}
onRefresh={handleRefresh}
refreshing={refreshing}
renderItem={renderItem}
scrollToOverflowEnabled={true}
onViewableItemsChanged={onViewableItemsChanged}
testID='pinned_messages.post_list.flat_list'
/>
</ExtraKeyboardProvider>
</SafeAreaView>
);
}
Expand Down