TagSpaces is an offline, open source, document manager with tagging support
implementing connection check for object store locations
Ilian Sapundshiev091230d7b03e
diff --git a/app/reducers/app.js b/app/reducers/app.jsindex 78fe3fbbd..481e97121 100644--- a/app/reducers/app.js+++ b/app/reducers/app.js@@ -927,18 +927,30 @@ export const actions = {locations.map(location => {if (location.uuid === locationId) {if (location.type === locationType.TYPE_CLOUD) {- PlatformIO.enableObjectStoreSupport(location);+ PlatformIO.enableObjectStoreSupport(location).then(() => {+ dispatch(actions.showNotification('Connected to object store', 'default', true));+ dispatch(actions.setReadOnlyMode(location.isReadOnly || false));+ dispatch(actions.setCurrentLocationId(location.uuid));+ dispatch(actions.loadDirectoryContent(location.paths[0]));+ if (locationId !== currentLocationId) {+ dispatch(actions.createDirectoryIndex(location.paths[0]));+ }+ return true;+ }).catch(() => {+ dispatch(actions.showNotification('Connection to object store failed!', 'warning', true));+ PlatformIO.disableObjectStoreSupport();+ });} else { // if (location.type === locationType.TYPE_LOCAL) {PlatformIO.disableObjectStoreSupport();- }- dispatch(actions.setReadOnlyMode(location.isReadOnly || false));- dispatch(actions.setCurrentLocationId(location.uuid));- dispatch(actions.loadDirectoryContent(location.paths[0]));- if (locationId !== currentLocationId) {- dispatch(actions.createDirectoryIndex(location.paths[0]));- }- if (Pro && Pro.Watcher && location.watchForChanges) {- Pro.Watcher.watchFolder(location.paths[0], dispatch, actions);+ dispatch(actions.setReadOnlyMode(location.isReadOnly || false));+ dispatch(actions.setCurrentLocationId(location.uuid));+ dispatch(actions.loadDirectoryContent(location.paths[0]));+ if (locationId !== currentLocationId) {+ dispatch(actions.createDirectoryIndex(location.paths[0]));+ }+ if (Pro && Pro.Watcher && location.watchForChanges) {+ Pro.Watcher.watchFolder(location.paths[0], dispatch, actions);+ }}}return true;diff --git a/app/services/platform-io.js b/app/services/platform-io.jsindex 4c8fc6af7..f8203af34 100644--- a/app/services/platform-io.js+++ b/app/services/platform-io.js@@ -35,14 +35,19 @@ if (AppConfig.isElectron) {let objectStoreAPI;export default class PlatformIO {- static enableObjectStoreSupport = (objectStoreConfig: Object): void => {+ static enableObjectStoreSupport = (objectStoreConfig: Object): Promise<any> => new Promise((resolve, reject) => {if (Pro && Pro.ObjectStoreIO) {objectStoreAPI = new Pro.ObjectStoreIO();- objectStoreAPI.configure(objectStoreConfig);+ objectStoreAPI.configure(objectStoreConfig).then(() => {+ resolve();+ return true;+ }).catch((e) => {+ reject(e);+ });} else {- console.log('ObjectStore support available in the PRO version');+ reject('ObjectStore support available in the PRO version');}- };+ });static disableObjectStoreSupport = (): void => {objectStoreAPI = undefined;