Fix search
This commit is contained in:
parent
330ab40e16
commit
2b1f78f3ec
|
@ -72,8 +72,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
|
||||||
];
|
];
|
||||||
|
|
||||||
if (text?.trim()) {
|
if (text?.trim()) {
|
||||||
whereClause.push(Q.where('msg', Q.like(`%${ sanitizeLikeString(text?.trim()) }%`)),
|
whereClause.push(Q.where('msg', Q.like(`%${ sanitizeLikeString(text?.trim()) }%`)));
|
||||||
Q.where('username', Q.like(`%${ sanitizeLikeString(text?.trim()) }%`)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const discussionsMessages = await db
|
const discussionsMessages = await db
|
||||||
|
@ -107,7 +106,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
|
||||||
/>
|
/>
|
||||||
</HeaderButton.Container>
|
</HeaderButton.Container>
|
||||||
),
|
),
|
||||||
headerTitle: () => <SearchHeader onSearchChangeText={onSearchChangeText} />,
|
headerTitle: () => <SearchHeader placeholder='Search by first message' onSearchChangeText={onSearchChangeText} />,
|
||||||
headerTitleContainerStyle: {
|
headerTitleContainerStyle: {
|
||||||
left: headerTitlePosition.left,
|
left: headerTitlePosition.left,
|
||||||
right: headerTitlePosition.right
|
right: headerTitlePosition.right
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import { StyleSheet, View } from 'react-native';
|
import { StyleSheet, View } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { withTheme } from '../../theme';
|
import { useTheme, withTheme } from '../../theme';
|
||||||
import sharedStyles from '../Styles';
|
import sharedStyles from '../Styles';
|
||||||
import { themes } from '../../constants/colors';
|
import { themes } from '../../constants/colors';
|
||||||
import TextInput from '../../presentation/TextInput';
|
import TextInput from '../../presentation/TextInput';
|
||||||
|
@ -21,7 +21,8 @@ const styles = StyleSheet.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: it might be useful to refactor this component for reusage
|
// 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 titleColorStyle = { color: themes[theme].headerTitleColor };
|
||||||
const isLight = theme === 'light';
|
const isLight = theme === 'light';
|
||||||
const { isLandscape } = useOrientation();
|
const { isLandscape } = useOrientation();
|
||||||
|
@ -33,7 +34,7 @@ const SearchHeader = ({ theme, onSearchChangeText }) => {
|
||||||
<TextInput
|
<TextInput
|
||||||
autoFocus
|
autoFocus
|
||||||
style={[styles.title, isLight && titleColorStyle, { fontSize: titleFontSize }]}
|
style={[styles.title, isLight && titleColorStyle, { fontSize: titleFontSize }]}
|
||||||
placeholder='Search'
|
placeholder={placeholder || 'Search'}
|
||||||
onChangeText={onSearchChangeText}
|
onChangeText={onSearchChangeText}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
testID='thread-messages-view-search-header'
|
testID='thread-messages-view-search-header'
|
||||||
|
@ -43,7 +44,7 @@ const SearchHeader = ({ theme, onSearchChangeText }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
SearchHeader.propTypes = {
|
SearchHeader.propTypes = {
|
||||||
theme: PropTypes.string,
|
onSearchChangeText: PropTypes.func,
|
||||||
onSearchChangeText: PropTypes.func
|
placeholder: PropTypes.string
|
||||||
};
|
};
|
||||||
export default withTheme(SearchHeader);
|
export default withTheme(SearchHeader);
|
||||||
|
|
Loading…
Reference in New Issue