Skip to content

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

Android issues v.3, fix hamburger menu (#1466)

Stanimird7d634301176
diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsx
index fa4be8a9d..c1d744cc6 100644
--- a/app/containers/MainPage.tsx
+++ b/app/containers/MainPage.tsx
@@ -408,13 +408,12 @@ const MainPage = (props: Props) => {
};
const showDrawer = () => {
- if (
- !props.isLocationManagerPanelOpened &&
+ /* if (
+ !props.isLocationManagerPanelOpened && // TODO this is true in Cordova on closed Locations && LocationManagerPanel
!props.isSearchPanelOpened &&
!props.isTagLibraryPanelOpened
- ) {
- props.openLocationManagerPanel();
- }
+ ) { */
+ props.openLocationManagerPanel();
// setDrawerOpened(true);
};
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index 8bc016635..9fd6276de 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -439,31 +439,36 @@ const GridPerspective = (props: Props) => {
);
if (fsEntry.isFile) {
if (!desktopMode) {
- if (selectedEntries && isEntryExist) {
+ if (!isEntryExist) {
+ if (selectedEntries.length > 0) {
+ props.setSelectedEntries([...selectedEntries, fsEntry]);
+ } else {
+ props.setSelectedEntries([fsEntry]);
+ }
+ } /* else { // deselect selected entry
props.setSelectedEntries(
selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid)
- ); // deselect selected entry
- } else {
+ );
+ } */
+ } else if (
+ props.selectedEntries.length === 0 ||
+ !fileOperationsEnabled()
+ ) {
+ props.setSelectedEntries([fsEntry]);
+ } else if (event.ctrlKey) {
+ if (!isEntryExist) {
props.setSelectedEntries([...selectedEntries, fsEntry]);
}
+ } else if (isEntryExist) {
+ // update selected entry
+ props.setSelectedEntries([
+ ...selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid),
+ fsEntry
+ ]);
} else {
- if (props.selectedEntries.length === 0 || !fileOperationsEnabled()) {
- props.setSelectedEntries([fsEntry]);
- } else if (event.ctrlKey) {
- if (!isEntryExist) {
- props.setSelectedEntries([...selectedEntries, fsEntry]);
- }
- } else if (isEntryExist) {
- // update selected entry
- props.setSelectedEntries([
- ...selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid),
- fsEntry
- ]);
- } else {
- props.setSelectedEntries([fsEntry]);
- }
- setFileContextMenuAnchorEl(event.currentTarget);
+ props.setSelectedEntries([fsEntry]);
}
+ setFileContextMenuAnchorEl(event.currentTarget);
} else {
if (props.selectedEntries.length === 0 || !folderOperationsEnabled()) {
props.setSelectedEntries([fsEntry]);
diff --git a/app/services/cordova-io.ts b/app/services/cordova-io.ts
index af392d308..55e01aba6 100644
--- a/app/services/cordova-io.ts
+++ b/app/services/cordova-io.ts
@@ -24,7 +24,8 @@ import {
cleanTrailingDirSeparator,
extractFileName,
extractFileExtension,
- getMetaFileLocationForDir
+ getMetaFileLocationForDir,
+ getThumbFileLocationForDirectory
} from '-/utils/paths';
import { TS } from '-/tagspaces.namespace';
@@ -228,7 +229,7 @@ export default class CordovaIO {
return new Promise((resolve, reject) => {
window.resolveLocalFileSystemURL(dirPath, resolve, error => {
console.error(
- 'Error getting FileSystem' +
+ 'Error getting FileSystem ' +
dirPath +
': ' +
this.cordovaFileError[error.code]
@@ -525,11 +526,10 @@ export default class CordovaIO {
eentry.tags = [];
eentry.thumbPath = entry.isFile
? ''
- : eentry.path +
- '/' +
- AppConfig.metaFolder +
- '/' +
- AppConfig.folderThumbFile;
+ : getThumbFileLocationForDirectory(
+ eentry.path,
+ AppConfig.dirSeparator
+ );
// eentry.meta = {};
eentry.isFile = entry.isFile;
if (entry.isFile) {
@@ -1008,67 +1008,72 @@ export default class CordovaIO {
/**
* Copies a given file to a specified location
*/
- copyFilePromise = (filePath: string, newFilePath: string): Promise<any> =>
- new Promise((resolve, reject) => {
- this.checkFileExist(newFilePath).then(exist => {
+ copyFilePromise = (
+ filePath: string,
+ newFilePath: string,
+ override: boolean = true
+ ): Promise<any> =>
+ new Promise(async (resolve, reject) => {
+ if (!override) {
+ const exist = await this.checkFileExist(newFilePath);
if (exist) {
reject('error copyFile: ' + newFilePath + ' exist!');
return;
}
- // eslint-disable-next-line no-param-reassign
- filePath = this.normalizePath(filePath);
- const newFileName = newFilePath.substring(
- newFilePath.lastIndexOf('/') + 1
- );
- const newFileParentPath = this.normalizePath(
- newFilePath.substring(0, newFilePath.lastIndexOf('/'))
- );
- this.fsRoot.getDirectory(
- newFileParentPath,
- {
- create: false,
- exclusive: false
- },
- parentDirEntry => {
- this.fsRoot.getFile(
- filePath,
- {
- create: false,
- exclusive: false
- },
- entry => {
- entry.copyTo(
- parentDirEntry,
- newFileName,
- () => {
- console.log(
- 'File copy: target: ' +
- newFilePath +
- ' source: ' +
- entry.fullPath
- );
- resolve(newFilePath);
- },
- () => {
- reject('error copying: ' + filePath);
- }
- );
- },
- () => {
- reject('Error getting file: ' + filePath);
- }
- );
- },
- error => {
- reject(
- 'Getting dir: ' +
- newFileParentPath +
- ' failed with error code: ' +
- error.code
- );
- }
- );
- });
+ }
+ // eslint-disable-next-line no-param-reassign
+ filePath = this.normalizePath(filePath);
+ const newFileName = newFilePath.substring(
+ newFilePath.lastIndexOf('/') + 1
+ );
+ const newFileParentPath = this.normalizePath(
+ newFilePath.substring(0, newFilePath.lastIndexOf('/'))
+ );
+ this.fsRoot.getDirectory(
+ newFileParentPath,
+ {
+ create: false,
+ exclusive: false
+ },
+ parentDirEntry => {
+ this.fsRoot.getFile(
+ filePath,
+ {
+ create: false,
+ exclusive: false
+ },
+ entry => {
+ entry.copyTo(
+ parentDirEntry,
+ newFileName,
+ () => {
+ console.log(
+ 'File copy: target: ' +
+ newFilePath +
+ ' source: ' +
+ entry.fullPath
+ );
+ resolve(newFilePath);
+ },
+ () => {
+ reject('error copying: ' + filePath);
+ }
+ );
+ },
+ () => {
+ reject('Error getting file: ' + filePath);
+ }
+ );
+ },
+ error => {
+ reject(
+ 'Getting dir: ' +
+ newFileParentPath +
+ ' failed with error code: ' +
+ error.code
+ );
+ }
+ );
});
/**
diff --git a/app/services/electron-io.ts b/app/services/electron-io.ts
index c48e61645..27225a989 100644
--- a/app/services/electron-io.ts
+++ b/app/services/electron-io.ts
@@ -23,7 +23,8 @@ import {
extractFileExtension,
extractFileName,
extractParentDirectoryPath,
- getMetaDirectoryPath
+ getMetaDirectoryPath,
+ getThumbFileLocationForDirectory
} from '-/utils/paths';
import { arrayBufferToBuffer } from '-/utils/misc';
import AppConfig from '../config';
@@ -98,8 +99,14 @@ export default class ElectronIO {
nImage = nativeImage.createFromDataURL(TrayIcon2x);
} else if (process.platform === 'darwin') {
nImage = nativeImage.createFromDataURL(TrayIcon);
- nImage.addRepresentation({ scaleFactor: 2.0, dataURL: TrayIcon2x });
- nImage.addRepresentation({ scaleFactor: 3.0, dataURL: TrayIcon3x });
+ nImage.addRepresentation({
+ scaleFactor: 2.0,
+ dataURL: TrayIcon2x
+ });
+ nImage.addRepresentation({
+ scaleFactor: 3.0,
+ dataURL: TrayIcon3x
+ });
} else {
nImage = nativeImage.createFromDataURL(TrayIcon2x);
}
@@ -348,8 +355,7 @@ export default class ElectronIO {
: '') +
AppConfig.metaFolderFile;
try {
- const folderMeta = this.fs.readJsonSync(folderMetaPath);
- eentry.meta = folderMeta;
+ eentry.meta = this.fs.readJsonSync(folderMetaPath);
// console.log('Success reading meta folder file ' + folderMetaPath);
} catch (err) {
// console.log('Failed reading meta folder file ' + folderMetaPath);
@@ -358,12 +364,10 @@ export default class ElectronIO {
// Loading thumbs for folders
if (!eentry.path.includes('/' + AppConfig.metaFolder)) {
// skipping meta folder
- const folderTmbPath =
- eentry.path +
- AppConfig.dirSeparator +
- AppConfig.metaFolder +
- AppConfig.dirSeparator +
- AppConfig.folderThumbFile;
+ const folderTmbPath = getThumbFileLocationForDirectory(
+ eentry.path,
+ AppConfig.dirSeparator
+ );
const tmbStats = this.fs.statSync(folderTmbPath);
if (tmbStats.isFile()) {
eentry.thumbPath = folderTmbPath;
diff --git a/app/services/objectstore-io.ts b/app/services/objectstore-io.ts
index 549880896..fce5d8fcc 100644
--- a/app/services/objectstore-io.ts
+++ b/app/services/objectstore-io.ts
@@ -27,7 +27,8 @@ import {
getThumbFileLocationForFile,
getMetaFileLocationForFile,
extractFileExtension,
- getMetaFileLocationForDir
+ getMetaFileLocationForDir,
+ getThumbFileLocationForDirectory
} from '-/utils/paths';
import { TS } from '-/tagspaces.namespace';
@@ -326,11 +327,10 @@ export default class ObjectStoreIO {
!eentry.path.includes(AppConfig.metaFolder + '/')
) {
// skipping meta folder
- const folderTmbPath =
- eentry.path +
- AppConfig.metaFolder +
- '/' +
- AppConfig.folderThumbFile;
+ const folderTmbPath = getThumbFileLocationForDirectory(
+ eentry.path,
+ AppConfig.dirSeparator
+ );
const folderThumbProps = await this.getPropertiesPromise(
folderTmbPath
);