Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fix crash after close search - Esc on saved search

sytolk5a6c85ddb7c1
diff --git a/src/renderer/hooks/DirectoryContentContextProvider.tsx b/src/renderer/hooks/DirectoryContentContextProvider.tsx
index 2684ed01a..74665d9e3 100644
--- a/src/renderer/hooks/DirectoryContentContextProvider.tsx
+++ b/src/renderer/hooks/DirectoryContentContextProvider.tsx
@@ -978,36 +978,42 @@ export const DirectoryContentContextProvider = ({
location: CommonLocation = undefined,
): Promise<boolean> {
if (dirPath !== undefined) {
- const cLocation = location || currentLocation;
- return cLocation.checkDirExist(dirPath).then((exist) => {
- if (exist) {
- const reloadMeta =
- cleanTrailingDirSeparator(currentDirectoryPath.current) ===
- cleanTrailingDirSeparator(dirPath);
- return loadMetaDirectoryContent(dirPath, cLocation, showHiddenEntries)
- .then((dirEntries) => {
- if (dirEntries && reloadMeta) {
- // load meta files (reload of the same directory is not handled from ThumbGenerationContextProvider)
- return loadCurrentDirMeta(dirPath, dirEntries).then(
- (entries) => {
- updateCurrentDirEntries(entries);
- return true;
- },
- );
- }
- return true;
- })
- .then(() => {
- setReflectMetaActions({
- action: 'thumbGenerate',
+ const cLocation = location || findLocation();
+ if (cLocation) {
+ return cLocation.checkDirExist(dirPath).then((exist) => {
+ if (exist) {
+ const reloadMeta =
+ cleanTrailingDirSeparator(currentDirectoryPath.current) ===
+ cleanTrailingDirSeparator(dirPath);
+ return loadMetaDirectoryContent(
+ dirPath,
+ cLocation,
+ showHiddenEntries,
+ )
+ .then((dirEntries) => {
+ if (dirEntries && reloadMeta) {
+ // load meta files (reload of the same directory is not handled from ThumbGenerationContextProvider)
+ return loadCurrentDirMeta(dirPath, dirEntries).then(
+ (entries) => {
+ updateCurrentDirEntries(entries);
+ return true;
+ },
+ );
+ }
+ return true;
+ })
+ .then(() => {
+ setReflectMetaActions({
+ action: 'thumbGenerate',
+ });
+ return true;
});
- return true;
- });
- } else {
- showNotification(t('core:invalidLink'), 'warning', true);
- return false;
- }
- });
+ } else {
+ showNotification(t('core:invalidLink'), 'warning', true);
+ return false;
+ }
+ });
+ }
}
return Promise.resolve(false);
}