Skip to content

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

Adding a thumnbail to a subfolder is not reflected without refresh

sytolka94ee61c0669
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index aacc948e3..66651c7ae 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -173,7 +173,7 @@ interface Props {
sharingLink: string;
tileServer: TS.MapTileServer;
lastBackgroundImageChange: number;
- lastThumbnailImageChange: number;
+ lastThumbnailImageChange: any;
}
const defaultBackgrounds = [
@@ -576,8 +576,9 @@ function EntryProperties(props: Props) {
if (thumbPath !== undefined) {
url =
normalizeUrl(thumbPath) +
- (props.lastThumbnailImageChange
- ? '?' + props.lastThumbnailImageChange
+ (props.lastThumbnailImageChange &&
+ props.lastThumbnailImageChange.thumbPath === thumbPath
+ ? '?' + props.lastThumbnailImageChange.dt
: '');
}
if (bgndPath !== undefined) {
@@ -1384,7 +1385,8 @@ function mapActionCreatorsToProps(dispatch) {
const areEqual = (prevProp: Props, nextProp: Props) =>
JSON.stringify(nextProp.openedEntry) ===
JSON.stringify(prevProp.openedEntry) &&
- nextProp.lastThumbnailImageChange === prevProp.lastThumbnailImageChange;
+ JSON.stringify(nextProp.lastThumbnailImageChange) ===
+ JSON.stringify(prevProp.lastThumbnailImageChange);
export default withLeaflet(
connect(
diff --git a/app/perspectives/grid-perspective/components/CellContent.tsx b/app/perspectives/grid-perspective/components/CellContent.tsx
index 3be41d9b6..f8f226443 100644
--- a/app/perspectives/grid-perspective/components/CellContent.tsx
+++ b/app/perspectives/grid-perspective/components/CellContent.tsx
@@ -80,7 +80,7 @@ interface Props {
handleGridCellClick: (event: Object, fsEntry: TS.FileSystemEntry) => void;
editTagForEntry?: (path: string, tag: TS.Tag) => void;
reorderTags: boolean;
- lastThumbnailImageChange: number;
+ lastThumbnailImageChange: any;
}
function CellContent(props: Props) {
@@ -182,10 +182,12 @@ function CellContent(props: Props) {
src={
fsEntry.thumbPath +
(props.lastThumbnailImageChange &&
+ props.lastThumbnailImageChange.thumbPath ===
+ fsEntry.thumbPath &&
!PlatformIO.haveObjectStoreSupport() &&
!PlatformIO.haveWebDavSupport()
? urlGetDelim(fsEntry.thumbPath) +
- props.lastThumbnailImageChange
+ props.lastThumbnailImageChange.dt
: '')
}
// @ts-ignore
@@ -410,10 +412,12 @@ function CellContent(props: Props) {
src={
fsEntry.thumbPath +
(props.lastThumbnailImageChange &&
+ props.lastThumbnailImageChange.thumbPath ===
+ fsEntry.thumbPath &&
!PlatformIO.haveObjectStoreSupport() &&
!PlatformIO.haveWebDavSupport()
? urlGetDelim(fsEntry.thumbPath) +
- props.lastThumbnailImageChange
+ props.lastThumbnailImageChange.dt
: '')
}
// @ts-ignore
diff --git a/app/perspectives/grid-perspective/components/GridPagination.tsx b/app/perspectives/grid-perspective/components/GridPagination.tsx
index 6f81c25b1..76e51715f 100644
--- a/app/perspectives/grid-perspective/components/GridPagination.tsx
+++ b/app/perspectives/grid-perspective/components/GridPagination.tsx
@@ -107,7 +107,7 @@ interface Props {
selectedEntries; // cache only
// setMetaForCurrentDir: (metaFiles: Array<any>) => void;
lastBackgroundImageChange: number;
- lastThumbnailImageChange: number;
+ lastThumbnailImageChange: any;
setSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => void;
singleClickAction: string;
currentLocation: TS.Location;
@@ -714,7 +714,8 @@ function mapActionCreatorsToProps(dispatch) {
const areEqual = (prevProp: Props, nextProp: Props) =>
nextProp.theme === prevProp.theme &&
nextProp.lastBackgroundImageChange === prevProp.lastBackgroundImageChange &&
- nextProp.lastThumbnailImageChange === prevProp.lastThumbnailImageChange &&
+ JSON.stringify(nextProp.lastThumbnailImageChange) ===
+ JSON.stringify(prevProp.lastThumbnailImageChange) &&
nextProp.currentDirectoryPath === prevProp.currentDirectoryPath &&
nextProp.isMetaLoaded === prevProp.isMetaLoaded &&
nextProp.showDirectories === prevProp.showDirectories &&
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 2922240b6..640d9e0f3 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -262,7 +262,10 @@ export default (state: any = initialState, action: any) => {
case types.LAST_THUMBNAIL_IMAGE_CHANGE: {
return {
...state,
- lastThumbnailImageChange: action.lastThumbnailImageChange
+ lastThumbnailImageChange: {
+ thumbPath: action.thumbPath,
+ dt: action.lastThumbnailImageChange
+ }
};
}
case types.LOGIN_SUCCESS: {
@@ -909,9 +912,14 @@ export const actions = {
type: types.LAST_BACKGROUND_IMAGE_CHANGE,
lastBackgroundImageChange
}),
- setLastThumbnailImageChange: lastThumbnailImageChange => ({
+ /**
+ * @param thumbPath
+ * @param lastThumbnailImageChange - timestamp set -1 if thumbnail image deleted
+ */
+ setLastThumbnailImageChange: (thumbPath, lastThumbnailImageChange?) => ({
type: types.LAST_THUMBNAIL_IMAGE_CHANGE,
- lastThumbnailImageChange
+ thumbPath,
+ lastThumbnailImageChange: lastThumbnailImageChange || new Date().getTime()
}),
loggedIn: user => ({ type: types.LOGIN_SUCCESS, user }),
initApp: () => (dispatch: (action) => void, getState: () => any) => {
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index b440fb17e..283a0e522 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -1323,7 +1323,7 @@ function mergeTags(oldTagsArray: Array<TS.Tag>, newTagsArray: Array<TS.Tag>) {
export function getFolderThumbPath(
path: string,
- lastThumbnailImageChange: number
+ lastThumbnailImageChange: any
) {
return getThumbPath(
getThumbFileLocationForDirectory(path, PlatformIO.getDirSeparator()),
@@ -1331,10 +1331,7 @@ export function getFolderThumbPath(
);
}
-export function getThumbPath(
- thumbPath: string,
- lastThumbnailImageChange: number
-) {
+export function getThumbPath(thumbPath: string, lastThumbnailImageChange: any) {
if (!thumbPath) {
return undefined;
}
@@ -1346,7 +1343,10 @@ export function getThumbPath(
}
return (
normalizeUrl(thumbPath) +
- (lastThumbnailImageChange ? '?' + lastThumbnailImageChange : '')
+ (lastThumbnailImageChange &&
+ lastThumbnailImageChange.thumbPath === thumbPath
+ ? '?' + lastThumbnailImageChange.dt
+ : '')
);
}