Skip to content

Commit

Permalink
[ENG-1269] Search options (#1561)
Browse files Browse the repository at this point in the history
* search options start

* small progress

* more

* bunch of stuff

* semi functioning filters

* cleanup setup api

* progress

* remove filters

* hooked up to query epic moment

* fix

* move db stuff to specific modules

* in/notIn for some fields

* generate ts

* big gains

* working filter options for locations, tags and kind

* working search query

* perfect fixed filters

* saved searches lol

* merge error

* saved searches via api

* better routing

* [ENG-1338] Fix fresh Spacedrive install failing to start due to attempting to query a nonexistent Library (#1649)

Fix Spacedrive failing to start due to attempting to query a nonexistent Library
 - Rename useShoudRedirect to useRedirectToNewLocations
 - Improve behaviour for the immedite redirection after adding a new location

* Show hidden files false by default (#1652)

bool

* fix remove filter in list

* tweaks

* fix nav buttons

* unify MediaData search handling

* cleanup saved search writing

* Add left top bar portals for tags and search + fixed media view on tags

* added search to filter dropdown

* render cycle improvements

* hotfix

* wip

* Refactor with Brendan, but this is a WIP and the search query no longer works

Co-authored-by: Brendan Allan <[email protected]>

* progress

* fix location/$id page

* fix tags too

Co-authored-by: Brendan Allan <[email protected]>

* 3rd refactor lol

epic style

* half-done with enum-ification of SearchFilterArgs

* broken fixed filters but working inNotIn filters

* search name + extension kinda working

* hidden filter

* fixed filters working??

* deferred search value

* extensions works

* filtered search items mostly working

* tweaks

* stacked approach working for non-search filters

* move to Explorer/Search

* actually use filterArgs in queries

things actually work properly now

* added new icons from Mint

* goof

* cleanup types, filters and mutation logic

* actually use search value

* remove overview from sidebar

* don't shrink LibrariesDropdown ga

* remove overview from sidebar and default to /network

---------

Co-authored-by: Brendan Allan <[email protected]>
Co-authored-by: Vítor Vasconcellos <[email protected]>
Co-authored-by: Brendan Allan <[email protected]>
  • Loading branch information
4 people committed Nov 17, 2023
1 parent 0ef65fc commit 27f077e
Show file tree
Hide file tree
Showing 98 changed files with 4,424 additions and 4,347 deletions.
926 changes: 410 additions & 516 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions apps/mobile/src/screens/Location.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ export default function LocationScreen({ navigation, route }: SharedScreenProps<
const { data } = useLibraryQuery([
'search.paths',
{
filter: {
locationId: id,
path: path ?? ''
},
filters: [
{
filePath: {
locations: { in: [id] },
path: { path: path ?? '', location_id: id, include_descendants: false }
}
}
],
take: 100
}
]);
Expand Down
17 changes: 13 additions & 4 deletions apps/mobile/src/screens/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MagnifyingGlass } from 'phosphor-react-native';
import { Suspense, useDeferredValue, useMemo, useState } from 'react';
import { ActivityIndicator, Pressable, Text, TextInput, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { getExplorerItemData, useLibraryQuery } from '@sd/client';
import { getExplorerItemData, SearchFilterArgs, useLibraryQuery } from '@sd/client';
import Explorer from '~/components/explorer/Explorer';
import { tw, twStyle } from '~/lib/tailwind';
import { RootStackScreenProps } from '~/navigation';
Expand All @@ -18,14 +18,23 @@ const SearchScreen = ({ navigation }: RootStackScreenProps<'Search'>) => {
const [search, setSearch] = useState('');
const deferredSearch = useDeferredValue(search);

const filters = useMemo(() => {
const [name, ext] = deferredSearch.split('.');

const filters: SearchFilterArgs[] = [];

if (name) filters.push({ filePath: { name: { contains: name } } });
if (ext) filters.push({ filePath: { extension: { in: [ext] } } });

return filters;
}, [deferredSearch]);

const query = useLibraryQuery(
[
'search.paths',
{
// ...args,
filter: {
search: deferredSearch
},
filters,
take: 100
}
],
Expand Down
4 changes: 1 addition & 3 deletions apps/mobile/src/screens/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ export default function TagScreen({ navigation, route }: SharedScreenProps<'Tag'
const search = useLibraryQuery([
'search.objects',
{
filter: {
tags: [id]
},
filters: [{ object: { tags: { in: [id] } } }],
take: 100
}
]);
Expand Down
15 changes: 15 additions & 0 deletions core/prisma/migrations/20231022013532_saved_searches/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- CreateTable
CREATE TABLE "saved_search" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"pub_id" BLOB NOT NULL,
"filters" BLOB,
"name" TEXT,
"icon" TEXT,
"description" TEXT,
"order" INTEGER,
"date_created" DATETIME,
"date_modified" DATETIME
);

-- CreateIndex
CREATE UNIQUE INDEX "saved_search_pub_id_key" ON "saved_search"("pub_id");
14 changes: 14 additions & 0 deletions core/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,17 @@ model Notification {
@@map("notification")
}

model SavedSearch {
id Int @id @default(autoincrement())
pub_id Bytes @unique
filters Bytes?
name String?
icon String?
description String?
order Int? // Add this line to include ordering
date_created DateTime?
date_modified DateTime?
@@map("saved_search")
}
4 changes: 2 additions & 2 deletions core/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl BackendFeature {

mod auth;
mod backups;
mod categories;
// mod categories;
mod ephemeral_files;
mod files;
mod jobs;
Expand Down Expand Up @@ -173,7 +173,7 @@ pub(crate) fn mount() -> Arc<Router> {
.merge("library.", libraries::mount())
.merge("volumes.", volumes::mount())
.merge("tags.", tags::mount())
.merge("categories.", categories::mount())
// .merge("categories.", categories::mount())
// .merge("keys.", keys::mount())
.merge("locations.", locations::mount())
.merge("ephemeralFiles.", ephemeral_files::mount())
Expand Down

1 comment on commit 27f077e

@vercel
Copy link

@vercel vercel bot commented on 27f077e Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.