Skip to content

Commit a786062

Browse files
committed
feat: fixed issues with FTS stopped debugger so config files are correct
1 parent 3c6cc74 commit a786062

File tree

4 files changed

+104
-1
lines changed

4 files changed

+104
-1
lines changed

expo-example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ allprojects {
3939
maven { url 'https://www.jitpack.io' }
4040
}
4141
}
42-
apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"
42+
apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"apply from: "../../android/build.gradle"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import React, { useState } from 'react';
2+
import { Collection } from 'cbl-reactnative';
3+
import CBLCollectionActionContainer from '@/components/CBLCollectionActionContainer';
4+
import HeaderView from '@/components/HeaderView';
5+
import { Divider, Switch } from '@gluestack-ui/themed';
6+
import { StyledTextInput } from '@/components/StyledTextInput';
7+
import createFts from '@/service/indexes/createFts';
8+
import { View } from 'react-native';
9+
import { Text } from '@/components/Themed';
10+
11+
export default function IndexFtsCreateScreen() {
12+
const [indexName, setIndexName] = useState<string>('');
13+
const [ignoreAccents, setIgnoreAccents] = useState<boolean>(false);
14+
const [indexProperties, setIndexProperties] = useState<string>('');
15+
16+
function reset() {
17+
setIgnoreAccents(false);
18+
setIndexName('');
19+
setIndexProperties('');
20+
}
21+
22+
async function update(collection: Collection): Promise<string[]> {
23+
try {
24+
await createFts(collection, indexName, indexProperties, ignoreAccents);
25+
return [`Index ${indexName} was created successfully`];
26+
} catch (error) {
27+
// @ts-ignore
28+
return [error.message];
29+
}
30+
}
31+
32+
return (
33+
<CBLCollectionActionContainer
34+
handleUpdatePressed={update}
35+
handleResetPressed={reset}
36+
screenTitle="Create FTS Index"
37+
>
38+
<HeaderView name="Index" iconName="magnify" />
39+
<StyledTextInput
40+
autoCapitalize="none"
41+
placeholder="IndexName"
42+
onChangeText={(newText) => setIndexName(newText)}
43+
defaultValue={indexName}
44+
/>
45+
<Divider style={{ marginLeft: 8, marginTop: 10, marginBottom: 10 }} />
46+
<StyledTextInput
47+
style={{
48+
height: 120,
49+
minHeight: 20,
50+
marginBottom: 10,
51+
}}
52+
autoCapitalize="none"
53+
placeholder="Index Properties (comma separated)"
54+
onChangeText={(newText) => setIndexProperties(newText)}
55+
defaultValue={indexProperties}
56+
multiline={true}
57+
/>
58+
<Divider style={{ marginTop: 10, marginBottom: 10 }} />
59+
<View
60+
style={{
61+
flexDirection: 'row',
62+
justifyContent: 'space-between',
63+
alignItems: 'center',
64+
marginBottom: 16,
65+
}}
66+
>
67+
<Text style={{ paddingLeft: 6, fontSize: 16 }}>Ignore Accents</Text>
68+
<Switch
69+
style={{ paddingRight: 16 }}
70+
value={ignoreAccents}
71+
onValueChange={setIgnoreAccents}
72+
/>
73+
</View>
74+
</CBLCollectionActionContainer>
75+
);
76+
}

expo-example/ios/expoexample/Info.plist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
6565
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
6666
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
67+
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
6768
</array>
6869
<key>UILaunchStoryboardName</key>
6970
<string>SplashScreen</string>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Collection, FullTextIndexItem, IndexBuilder } from 'cbl-reactnative';
2+
3+
export default async function createFts(
4+
collection: Collection,
5+
indexName: string,
6+
indexProperties: string,
7+
ignoreAccents: boolean
8+
): Promise<void> {
9+
const rawIndexes = indexProperties
10+
.split(',')
11+
.map((property) => property.trim());
12+
if (rawIndexes.length > 0 && indexName.length > 0) {
13+
//create value index items to be added to the index using
14+
//IndexBuilder
15+
let valueIndexes: FullTextIndexItem[] = [];
16+
for (let i = 0; i < rawIndexes.length; i++) {
17+
const item = FullTextIndexItem.property(rawIndexes[i].trim());
18+
valueIndexes.push(item);
19+
}
20+
const index = IndexBuilder.fullTextIndex(...valueIndexes);
21+
index.setIgnoreAccents(ignoreAccents);
22+
await collection.createIndex(indexName, index);
23+
} else {
24+
throw new Error('Index name and properties are required');
25+
}
26+
}

0 commit comments

Comments
 (0)