Skip to content

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

fix: column background image and color is not refreshed on change (#1839)

Stanimir7d4245f6c913
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index e5fed75cc..17cb0e60f 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -172,8 +172,12 @@ interface Props {
tagDelimiter: string;
sharingLink: string;
tileServer: TS.MapTileServer;
- lastBackgroundImageChange: number;
+ lastBackgroundImageChange: any;
lastThumbnailImageChange: any;
+ setLastBackgroundColorChange: (
+ folderPath: string,
+ lastBackgroundColorChange: number
+ ) => void;
}
const defaultBackgrounds = [
@@ -462,8 +466,14 @@ function EntryProperties(props: Props) {
Pro.MetaOperations.saveColor(currentEntry.path, color)
.then(entryMeta => {
// if (props.entryPath === props.currentDirectoryPath) {
+ props.setLastBackgroundColorChange(
+ currentEntry.path,
+ new Date().getTime()
+ );
+ // todo handle LastBackgroundColorChange and skip updateOpenedFile
props.updateOpenedFile(currentEntry.path, entryMeta);
props.switchCurrentLocationType(currentLocationId);
+
/* } else {
setCurrentEntry({ ...currentEntry, color });
} */
@@ -596,8 +606,9 @@ function EntryProperties(props: Props) {
if (bgndPath !== undefined) {
bgndUrl =
normalizeUrl(bgndPath) +
- (props.lastBackgroundImageChange
- ? '?' + props.lastBackgroundImageChange
+ (props.lastBackgroundImageChange &&
+ props.lastBackgroundImageChange.folderPath === bgndPath
+ ? '?' + props.lastBackgroundImageChange.dt
: '');
}
}
@@ -1388,7 +1399,8 @@ function mapActionCreatorsToProps(dispatch) {
return bindActionCreators(
{
switchLocationType: LocationActions.switchLocationType,
- switchCurrentLocationType: AppActions.switchCurrentLocationType
+ switchCurrentLocationType: AppActions.switchCurrentLocationType,
+ setLastBackgroundColorChange: AppActions.setLastBackgroundColorChange
},
dispatch
);
@@ -1398,7 +1410,9 @@ const areEqual = (prevProp: Props, nextProp: Props) =>
JSON.stringify(nextProp.openedEntry) ===
JSON.stringify(prevProp.openedEntry) &&
JSON.stringify(nextProp.lastThumbnailImageChange) ===
- JSON.stringify(prevProp.lastThumbnailImageChange);
+ JSON.stringify(prevProp.lastThumbnailImageChange) &&
+ JSON.stringify(nextProp.lastBackgroundImageChange) ===
+ JSON.stringify(prevProp.lastBackgroundImageChange);
export default withLeaflet(
connect(
diff --git a/app/components/menus/FileMenu.tsx b/app/components/menus/FileMenu.tsx
index 08f18b360..fdc058940 100644
--- a/app/components/menus/FileMenu.tsx
+++ b/app/components/menus/FileMenu.tsx
@@ -89,7 +89,7 @@ interface Props {
selectedEntries: Array<any>;
currentLocation: TS.Location;
locations: Array<TS.Location>;
- setLastBackgroundImageChange: (number) => void;
+ setLastBackgroundImageChange: (path: string, dt: number) => void;
reorderTop?: () => void;
reorderBottom?: () => void;
}
@@ -174,7 +174,7 @@ function FileMenu(props: Props) {
setFolderBackgroundPromise(path, directoryPath)
.then((directoryPath: string) => {
- props.setLastBackgroundImageChange(new Date().getTime());
+ props.setLastBackgroundImageChange(path, new Date().getTime());
showNotification('Background created for: ' + directoryPath);
return true;
})
diff --git a/app/perspectives/grid-perspective/components/GridPagination.tsx b/app/perspectives/grid-perspective/components/GridPagination.tsx
index 7ef2ea367..42b63bd07 100644
--- a/app/perspectives/grid-perspective/components/GridPagination.tsx
+++ b/app/perspectives/grid-perspective/components/GridPagination.tsx
@@ -106,7 +106,7 @@ interface Props {
// eslint-disable-next-line react/no-unused-prop-types
selectedEntries; // cache only
// setMetaForCurrentDir: (metaFiles: Array<any>) => void;
- lastBackgroundImageChange: number;
+ lastBackgroundImageChange: any;
lastThumbnailImageChange: any;
setSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => void;
singleClickAction: string;
@@ -714,7 +714,8 @@ function mapActionCreatorsToProps(dispatch) {
const areEqual = (prevProp: Props, nextProp: Props) =>
nextProp.theme === prevProp.theme &&
- nextProp.lastBackgroundImageChange === prevProp.lastBackgroundImageChange &&
+ JSON.stringify(nextProp.lastBackgroundImageChange) ===
+ JSON.stringify(prevProp.lastBackgroundImageChange) &&
JSON.stringify(nextProp.lastThumbnailImageChange) ===
JSON.stringify(prevProp.lastThumbnailImageChange) &&
nextProp.currentDirectoryPath === prevProp.currentDirectoryPath &&
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 05fdd9356..f1f980a42 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -84,6 +84,7 @@ export const types = {
PROGRESS: 'APP/PROGRESS',
RESET_PROGRESS: 'APP/RESET_PROGRESS',
LAST_BACKGROUND_IMAGE_CHANGE: 'APP/LAST_BACKGROUND_IMAGE_CHANGE',
+ LAST_BACKGROUND_COLOR_CHANGE: 'APP/LAST_BACKGROUND_COLOR_CHANGE',
LAST_THUMBNAIL_IMAGE_CHANGE: 'APP/LAST_THUMBNAIL_IMAGE_CHANGE',
LOGIN_SUCCESS: 'APP/LOGIN_SUCCESS',
LOGIN_FAILURE: 'APP/LOGIN_FAILURE',
@@ -268,7 +269,19 @@ export default (state: any = initialState, action: any) => {
case types.LAST_BACKGROUND_IMAGE_CHANGE: {
return {
...state,
- lastBackgroundImageChange: action.lastBackgroundImageChange
+ lastBackgroundImageChange: {
+ folderPath: action.folderPath,
+ dt: action.lastBackgroundImageChange
+ }
+ };
+ }
+ case types.LAST_BACKGROUND_COLOR_CHANGE: {
+ return {
+ ...state,
+ lastBackgroundColorChange: {
+ folderPath: action.folderPath,
+ dt: action.lastBackgroundColorChange
+ }
};
}
case types.LAST_THUMBNAIL_IMAGE_CHANGE: {
@@ -824,8 +837,8 @@ export default (state: any = initialState, action: any) => {
case types.UPDATE_CURRENTDIR_ENTRY: {
return {
...state,
- // to reload cell in KanBan if add/remove sidecar tags
- // editedEntryPaths: [{ [action.path]: action.entry.tags }],
+ // warning: edit action is handled in FolderContainer; to reload column in KanBan if properties is changed (dir color)
+ // editedEntryPaths: [{ action: 'edit', path: action.path }],
currentDirectoryEntries: state.currentDirectoryEntries.map(entry => {
if (entry.path !== action.path) {
return entry;
@@ -952,10 +965,16 @@ function disableBackGestureMac() {
}
export const actions = {
- setLastBackgroundImageChange: lastBackgroundImageChange => ({
+ setLastBackgroundImageChange: (folderPath, lastBackgroundImageChange) => ({
type: types.LAST_BACKGROUND_IMAGE_CHANGE,
+ folderPath,
lastBackgroundImageChange
}),
+ setLastBackgroundColorChange: (folderPath, lastBackgroundColorChange) => ({
+ type: types.LAST_BACKGROUND_COLOR_CHANGE,
+ folderPath,
+ lastBackgroundColorChange
+ }),
/**
* @param thumbPath
* @param lastThumbnailImageChange - timestamp set -1 if thumbnail image deleted
@@ -2674,6 +2693,8 @@ export const actions = {
// Selectors
export const getLastBackgroundImageChange = (state: any) =>
state.app.lastBackgroundImageChange;
+export const getLastBackgroundColorChange = (state: any) =>
+ state.app.lastBackgroundColorChange;
export const getLastThumbnailImageChange = (state: any) =>
state.app.lastThumbnailImageChange;
export const currentUser = (state: any) => state.app.user;
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index 0743f352a..f4ce89d99 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -1362,7 +1362,7 @@ function isSignedURL(signedUrl) {
export function getFolderBgndPath(
path: string,
- lastBackgroundImageChange: number
+ lastBackgroundImageChange: any
) {
return getBgndPath(
getBgndFileLocationForDirectory(path, PlatformIO.getDirSeparator()),
@@ -1370,10 +1370,7 @@ export function getFolderBgndPath(
);
}
-export function getBgndPath(
- bgndPath: string,
- lastBackgroundImageChange: number
-) {
+export function getBgndPath(bgndPath: string, lastBackgroundImageChange: any) {
if (!bgndPath) {
return undefined;
}
@@ -1382,7 +1379,10 @@ export function getBgndPath(
}
return (
normalizeUrl(bgndPath) +
- (lastBackgroundImageChange ? '?' + lastBackgroundImageChange : '')
+ (lastBackgroundImageChange &&
+ lastBackgroundImageChange.folderPath === bgndPath
+ ? '?' + lastBackgroundImageChange.dt
+ : '')
);
}