TagSpaces is an offline, open source, document manager with tagging support
optimzing creation default location
Ilian Sapundshiev284773ada516
diff --git a/app/components/LocationManager.js b/app/components/LocationManager.jsindex e9c6c9725..dc5fd81cf 100644--- a/app/components/LocationManager.js+++ b/app/components/LocationManager.js@@ -81,7 +81,7 @@ type Props = {openDirectory: (path: string) => void,showInFileManager: (path: string) => void,createDirectoryIndex: (path: string) => void,- addLocation: () => void,+ addLocation: (location: Location) => void,editLocation: () => void,moveLocationUp: (locationId: string) => void,moveLocationDown: (locationId: string) => void,@@ -143,6 +143,24 @@ class LocationManager extends React.Component<Props, State> {dirs: {}};+ componentDidMount() {+ if (this.props.locations.length < 1) {+ const devicePaths = PlatformIO.getDevicePaths();++ Object.keys(devicePaths).forEach(key => {+ this.props.addLocation({+ uuid: uuidv1(),+ type: locationType.TYPE_LOCAL,+ name: key, // TODO use i18n+ paths: [devicePaths[key]],+ isDefault: (AppConfig.isWeb && devicePaths[key] === '/files/'), // Used for the web ts demo+ isReadOnly: false,+ persistIndex: false+ });+ });+ }+ }+loadSubDirectories = (location: Location, deepLevel: number) => {const subFolder = {uuid: location.uuid,diff --git a/app/reducers/locations.js b/app/reducers/locations.jsindex 8ce07b946..8895c66b9 100644--- a/app/reducers/locations.js+++ b/app/reducers/locations.js@@ -40,10 +40,10 @@ export type Location = {uuid: string,name: string,type: string,- accessKeyId: string,- secretAccessKey: string,- bucketName: string,- region: string,+ accessKeyId?: string,+ secretAccessKey?: string,+ bucketName?: string,+ region?: string,paths: Array<string>,perspective?: string, // id of the perspectivecreationDate?: string,@@ -56,20 +56,6 @@ export type Location = {export const initialState = [];-const devicePaths = PlatformIO.getDevicePaths();--Object.keys(devicePaths).forEach(key => {- initialState.push({- uuid: uuidv1(),- type: locationType.TYPE_LOCAL,- name: key, // TODO use i18n- paths: [devicePaths[key]],- isDefault: (AppConfig.isWeb && devicePaths[key] === '/files/'), // Used for the web ts demo- isReadOnly: false,- persistIndex: false- });-});-export default (state: Array<Location> = initialState, action: Object) => {switch (action.type) {case types.ADD_LOCATION: {