Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mugikhan committed Dec 18, 2024
1 parent 96622dd commit a6a9178
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
10 changes: 2 additions & 8 deletions demos/react-native-supabase-todolist/library/fts/fts_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export const SearchBarWidget: React.FC<any> = () => {
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]);
}
Expand Down

0 comments on commit a6a9178

Please sign in to comment.