From a6a9178c0173a109b227e4a350d7d72377bbae1d Mon Sep 17 00:00:00 2001 From: Mugi Khan Date: Wed, 18 Dec 2024 13:23:35 +0200 Subject: [PATCH] PR feedback --- .../library/fts/fts_helpers.ts | 10 ++-------- .../library/powersync/system.ts | 2 +- .../library/widgets/SearchBarWidget.tsx | 10 +++++----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/demos/react-native-supabase-todolist/library/fts/fts_helpers.ts b/demos/react-native-supabase-todolist/library/fts/fts_helpers.ts index 1b9d0be5..5d2a396b 100644 --- a/demos/react-native-supabase-todolist/library/fts/fts_helpers.ts +++ b/demos/react-native-supabase-todolist/library/fts/fts_helpers.ts @@ -26,14 +26,8 @@ export async function searchTable(searchTerm: string, tableName: string): Promis } //Used to display the search results in the autocomplete text field -export class SearchResult { +export interface SearchResult { id: string; - todoName: string | null; listName: string; - - constructor(id: string, listName: string, todoName: string | null = null) { - this.id = id; - this.listName = listName; - this.todoName = todoName; - } + todoName: string | null; } diff --git a/demos/react-native-supabase-todolist/library/powersync/system.ts b/demos/react-native-supabase-todolist/library/powersync/system.ts index 85d12364..d95650c4 100644 --- a/demos/react-native-supabase-todolist/library/powersync/system.ts +++ b/demos/react-native-supabase-todolist/library/powersync/system.ts @@ -72,7 +72,7 @@ export class System { // Demo using SQLite Full-Text Search with PowerSync. // See https://docs.powersync.com/usage-examples/full-text-search for more details - configureFts(this.powersync); + await configureFts(this.powersync); } } diff --git a/demos/react-native-supabase-todolist/library/widgets/SearchBarWidget.tsx b/demos/react-native-supabase-todolist/library/widgets/SearchBarWidget.tsx index eb9b2e89..ce5e35fc 100644 --- a/demos/react-native-supabase-todolist/library/widgets/SearchBarWidget.tsx +++ b/demos/react-native-supabase-todolist/library/widgets/SearchBarWidget.tsx @@ -24,11 +24,11 @@ export const SearchBarWidget: React.FC = () => { if (!todoItemsSearchResults.length) { listsSearchResults = await searchTable(value, 'lists'); } - const formattedListResults: SearchResult[] = listsSearchResults.map( - (result) => new SearchResult(result['id'], result['name']) - ); - const formattedTodoItemsResults: SearchResult[] = todoItemsSearchResults.map((result) => { - return new SearchResult(result['list_id'], result['list_name'] ?? '', result['description']); + const formattedListResults: SearchResult[] = listsSearchResults.map((result): SearchResult => { + return { id: result['id'], listName: result['name'], todoName: null }; + }); + const formattedTodoItemsResults: SearchResult[] = todoItemsSearchResults.map((result): SearchResult => { + return { id: result['list_id'], listName: result['list_name'] ?? '', todoName: result['description'] }; }); setSearchResults([...formattedTodoItemsResults, ...formattedListResults]); }