Fix search

This commit is contained in:
Gerzon Z 2021-09-03 11:11:57 -04:00
parent 330ab40e16
commit 2b1f78f3ec
2 changed files with 8 additions and 8 deletions

View File

@ -72,8 +72,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
];
if (text?.trim()) {
whereClause.push(Q.where('msg', Q.like(`%${ sanitizeLikeString(text?.trim()) }%`)),
Q.where('username', Q.like(`%${ sanitizeLikeString(text?.trim()) }%`)));
whereClause.push(Q.where('msg', Q.like(`%${ sanitizeLikeString(text?.trim()) }%`)));
}
const discussionsMessages = await db
@ -107,7 +106,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
/>
</HeaderButton.Container>
),
headerTitle: () => <SearchHeader onSearchChangeText={onSearchChangeText} />,
headerTitle: () => <SearchHeader placeholder='Search by first message' onSearchChangeText={onSearchChangeText} />,
headerTitleContainerStyle: {
left: headerTitlePosition.left,
right: headerTitlePosition.right

View File

@ -2,7 +2,7 @@ import React from 'react';
import { StyleSheet, View } from 'react-native';
import PropTypes from 'prop-types';
import { withTheme } from '../../theme';
import { useTheme, withTheme } from '../../theme';
import sharedStyles from '../Styles';
import { themes } from '../../constants/colors';
import TextInput from '../../presentation/TextInput';
@ -21,7 +21,8 @@ const styles = StyleSheet.create({
});
// TODO: it might be useful to refactor this component for reusage
const SearchHeader = ({ theme, onSearchChangeText }) => {
const SearchHeader = ({ onSearchChangeText, placeholder }) => {
const { theme } = useTheme();
const titleColorStyle = { color: themes[theme].headerTitleColor };
const isLight = theme === 'light';
const { isLandscape } = useOrientation();
@ -33,7 +34,7 @@ const SearchHeader = ({ theme, onSearchChangeText }) => {
<TextInput
autoFocus
style={[styles.title, isLight && titleColorStyle, { fontSize: titleFontSize }]}
placeholder='Search'
placeholder={placeholder || 'Search'}
onChangeText={onSearchChangeText}
theme={theme}
testID='thread-messages-view-search-header'
@ -43,7 +44,7 @@ const SearchHeader = ({ theme, onSearchChangeText }) => {
};
SearchHeader.propTypes = {
theme: PropTypes.string,
onSearchChangeText: PropTypes.func
onSearchChangeText: PropTypes.func,
placeholder: PropTypes.string
};
export default withTheme(SearchHeader);