Skip to content

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

fix: broken loading of file from cmd parameters

Ilian Sapundshiev0e7e0ec0d95b
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index db3843816..da7db45c1 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -473,11 +473,15 @@ function EntryContainer(props: Props) {
!openedFile.editMode
);
}
- return props.switchCurrentLocationType(currentLocationId);
+ if (currentLocationId) {
+ return props.switchCurrentLocationType(currentLocationId);
+ }
})
.catch(err => {
console.warn('Error loading text content ' + err);
- return props.switchCurrentLocationType(currentLocationId);
+ if (currentLocationId) {
+ return props.switchCurrentLocationType(currentLocationId);
+ }
});
});
break;
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index f1f980a42..0209e8796 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -1035,7 +1035,9 @@ export const actions = {
setTimeout(() => {
dispatch(
actions.openLink(
- window.location.href.split('?')[0] + '?cmdopen=' + cmdOpen
+ // window.location.href.split('?')[0] +
+ 'ts://?cmdopen=' + cmdOpen,
+ { fullWidth: true }
)
);
}, 1000);
@@ -2174,39 +2176,50 @@ export const actions = {
entryForOpening.editMode = true;
}
+ document.title = fsEntry.name + ' | ' + 'TagSpaces'; // TODO get it later from app config
+
const currentLocation: TS.Location = getLocation(
getState(),
getState().app.currentLocationId
);
- entryForOpening.locationId = currentLocation.uuid;
- const { currentDirectoryPath } = getState().app;
- updateHistory(currentLocation, currentDirectoryPath, fsEntry.path);
- document.title = fsEntry.name + ' | ' + 'TagSpaces'; // TODO get it later from app config
+ if (currentLocation) {
+ entryForOpening.locationId = currentLocation.uuid;
+ const { currentDirectoryPath } = getState().app;
+ updateHistory(currentLocation, currentDirectoryPath, fsEntry.path);
+ }
dispatch(actions.addToEntryContainer(entryForOpening));
- /**
- * save in history
- */
- if (Pro) {
- const historyKeys = Pro.history.historyKeys;
- const relEntryPath = getRelativeEntryPath(currentLocation, fsEntry.path);
- if (fsEntry.isFile) {
- Pro.history.saveHistory(
- historyKeys.fileOpenKey,
- fsEntry.path,
- generateSharingLink(currentLocation.uuid, relEntryPath),
- currentLocation.uuid,
- getState().settings[historyKeys.fileOpenKey]
- );
- } else {
- Pro.history.saveHistory(
- historyKeys.folderOpenKey,
- fsEntry.path,
- generateSharingLink(currentLocation.uuid, relEntryPath, relEntryPath),
- currentLocation.uuid,
- getState().settings[historyKeys.folderOpenKey]
+
+ // save in history
+ if (currentLocation) {
+ if (Pro) {
+ const historyKeys = Pro.history.historyKeys;
+ const relEntryPath = getRelativeEntryPath(
+ currentLocation,
+ fsEntry.path
);
+ if (fsEntry.isFile) {
+ Pro.history.saveHistory(
+ historyKeys.fileOpenKey,
+ fsEntry.path,
+ generateSharingLink(currentLocation.uuid, relEntryPath),
+ currentLocation.uuid,
+ getState().settings[historyKeys.fileOpenKey]
+ );
+ } else {
+ Pro.history.saveHistory(
+ historyKeys.folderOpenKey,
+ fsEntry.path,
+ generateSharingLink(
+ currentLocation.uuid,
+ relEntryPath,
+ relEntryPath
+ ),
+ currentLocation.uuid,
+ getState().settings[historyKeys.folderOpenKey]
+ );
+ }
}
}
},
@@ -2505,21 +2518,22 @@ export const actions = {
.then((fsEntry: TS.FileSystemEntry) => {
if (fsEntry.isFile) {
dispatch(actions.openFsEntry(fsEntry));
- dispatch(actions.setEntryFullWidth(true));
+ dispatch(actions.setEntryFullWidth(options.fullWidth));
} else {
dispatch(actions.loadDirectoryContent(fsEntry.path, false, true));
}
return true;
})
- .catch(() =>
+ .catch(err => {
+ // console.log('Error opening from cmd ' + JSON.stringify(err));
dispatch(
actions.showNotification(
- i18n.t('missing file or folder'),
+ i18n.t('Missing file or folder'),
'warning',
true
)
- )
- );
+ );
+ });
} else if (lid && lid.length > 0) {
const locationId = decodeURIComponent(lid);
const directoryPath = dPath && decodeURIComponent(dPath);
diff --git a/app/reducers/locations.ts b/app/reducers/locations.ts
index 8627fc843..d93a24894 100644
--- a/app/reducers/locations.ts
+++ b/app/reducers/locations.ts
@@ -255,6 +255,7 @@ export const actions = {
if (location) {
return dispatch(AppActions.switchLocationType(location));
}
+ return Promise.resolve(null);
},
changeLocation: (location: TS.Location) => ({
type: types.EDIT_LOCATION,