-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENG-1338] Fix fresh Spacedrive install failing to start due to attem…
…pting 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
- Loading branch information
1 parent
e51a58f
commit ce56898
Showing
7 changed files
with
53 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useNavigate } from 'react-router'; | ||
import { useLibraryQuery } from '@sd/client'; | ||
import { getExplorerStore, useExplorerStore } from '~/app/$libraryId/Explorer/store'; | ||
|
||
import { LibraryIdParamsSchema } from '../app/route-schemas'; | ||
import { useZodRouteParams } from './useZodRouteParams'; | ||
|
||
/** | ||
* When a user adds a location and checks the should redirect box, | ||
* this hook will redirect them to the location | ||
* once the indexer has been invoked | ||
*/ | ||
|
||
export const useRedirectToNewLocation = () => { | ||
const navigate = useNavigate(); | ||
const { libraryId } = useZodRouteParams(LibraryIdParamsSchema); | ||
const { newLocationToRedirect: newLocation } = useExplorerStore(); | ||
const { data: jobGroups } = useLibraryQuery(['jobs.reports'], { | ||
enabled: newLocation != null, | ||
refetchOnWindowFocus: false | ||
}); | ||
|
||
const hasIndexerJob = jobGroups | ||
?.flatMap((j) => j.jobs) | ||
.some( | ||
(j) => | ||
j.name === 'indexer' && | ||
j.metadata.location.id === newLocation && | ||
(j.completed_task_count > 0 || j.completed_at != null) | ||
); | ||
|
||
if (hasIndexerJob) { | ||
navigate(`/${libraryId}/location/${newLocation}`); | ||
getExplorerStore().newLocationToRedirect = null; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
ce56898
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
spacedrive-landing – ./apps/landing
spacedrive-landing-git-main-spacedrive.vercel.app
spacedrive-landing-spacedrive.vercel.app
spacedrive-landing.vercel.app
www.spacedrive.com
spacedrive.com