Skip to content

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

fix: flow issues

Ilian Sapundshievc0340914c6c9
diff --git a/app/services/onlineListener.js b/app/services/onlineListener.js
index 3a87af915..78f443235 100644
--- a/app/services/onlineListener.js
+++ b/app/services/onlineListener.js
@@ -19,7 +19,7 @@
import { actions as CommonActions } from '../reducers/app';
-export default function(dispatch) {
+export default (dispatch: any => void) => {
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
@@ -31,4 +31,4 @@ export default function(dispatch) {
dispatch(CommonActions.goOffline());
}
}
-}
+};
diff --git a/app/services/utils-io.js b/app/services/utils-io.js
index b2d6c8a3c..1918f2e6f 100644
--- a/app/services/utils-io.js
+++ b/app/services/utils-io.js
@@ -52,6 +52,7 @@ export type FileSystemEntry = {
export type FileSystemEntryMeta = {
description: string,
tags: Array<Tag>,
+ color?: string,
appVersionCreated: string,
appName: string,
appVersionUpdated: string,
@@ -395,7 +396,7 @@ export function generateFileName(
fileName.substring(endTagContainer + 1, fileName.length).trim();
}
if (newFileName.length < 1) {
- throw 'Generated filename is invalid';
+ throw new Error('Generated filename is invalid');
}
// Removing double prefix
newFileName = newFileName
diff --git a/app/utils/misc.js b/app/utils/misc.js
index 7c0f1d75d..e633ff6a3 100644
--- a/app/utils/misc.js
+++ b/app/utils/misc.js
@@ -200,7 +200,10 @@ export function formatFileSize(sizeInBytes): string {
// return sizeInBytes + ' B';
}
-export function formatFileSize2(sizeInBytes, siSystem): string {
+export function formatFileSize2(
+ sizeInBytes: number,
+ siSystem: boolean
+): string {
const threshold = siSystem ? 1000 : 1024;
if (!sizeInBytes) {
return '';
diff --git a/app/utils/paths.js b/app/utils/paths.js
index 691efa238..487e38a18 100644
--- a/app/utils/paths.js
+++ b/app/utils/paths.js
@@ -174,10 +174,11 @@ export function extractParentDirectoryPath(
dirSeparator: string = AppConfig.dirSeparator
) {
if (!dirPath) return;
- if (dirPath.endsWith(dirSeparator)) {
- dirPath = dirPath.substring(0, dirPath.lastIndexOf(dirSeparator));
+ let path = dirPath;
+ if (path.endsWith(dirSeparator)) {
+ path = path.substring(0, path.lastIndexOf(dirSeparator));
}
- return dirPath.substring(0, dirPath.lastIndexOf(dirSeparator));
+ return path.substring(0, path.lastIndexOf(dirSeparator));
}
export function extractDirectoryName(
@@ -259,7 +260,7 @@ export function extractTitle(entryPath: string, isDirectory?: boolean = false) {
export function extractTagsAsObjects(
filePath: string,
- tagDelimiter: string
+ tagDelimiter?: string
): Array<Tag> {
const tagsInFileName = extractTags(filePath, tagDelimiter);
const tagArray = [];
@@ -273,7 +274,7 @@ export function extractTagsAsObjects(
return tagArray;
}
-export function extractTags(filePath: string, tagDelimiter: string) {
+export function extractTags(filePath: string, tagDelimiter?: string) {
if (tagDelimiter === undefined) {
// TODO get tagDelimiter from settings reducer only
// eslint-disable-next-line no-param-reassign