diff --git a/src/backend/middlewares/SharingMWs.ts b/src/backend/middlewares/SharingMWs.ts index e4c0c68d..0ec63663 100644 --- a/src/backend/middlewares/SharingMWs.ts +++ b/src/backend/middlewares/SharingMWs.ts @@ -55,7 +55,9 @@ export class SharingMWs { path: directoryName, password: createSharing.password, creator: req.session.user, - expires: Date.now() + createSharing.valid, + expires: createSharing.valid >= 0 ? // if === -1 its forever + Date.now() + createSharing.valid : + (new Date(9999, 0, 1)).getTime(), // never expire includeSubfolders: createSharing.includeSubfolders, timeStamp: Date.now() }; @@ -86,7 +88,9 @@ export class SharingMWs { sharingKey: '', password: (updateSharing.password && updateSharing.password !== '') ? updateSharing.password : null, creator: req.session.user, - expires: Date.now() + updateSharing.valid, + expires: updateSharing.valid >= 0 // if === -1 its forever + ? Date.now() + updateSharing.valid : + (new Date(9999, 0, 1)).getTime(), // never expire includeSubfolders: updateSharing.includeSubfolders, timeStamp: Date.now() }; diff --git a/src/frontend/app/ui/gallery/gallery.component.ts b/src/frontend/app/ui/gallery/gallery.component.ts index ab98fbdd..b860390a 100644 --- a/src/frontend/app/ui/gallery/gallery.component.ts +++ b/src/frontend/app/ui/gallery/gallery.component.ts @@ -60,6 +60,11 @@ export class GalleryComponent implements OnInit, OnDestroy { if (this.shareService.sharingSubject.value == null) { return; } + // if the timer is longer than 10 years, just do not show it + if ((this.shareService.sharingSubject.value.expires - Date.now()) / 1000 / 86400 / 365 > 10) { + return; + } + t = Math.floor((this.shareService.sharingSubject.value.expires - Date.now()) / 1000); this.countDown = ({} as any); this.countDown.day = Math.floor(t / 86400); @@ -132,7 +137,7 @@ export class GalleryComponent implements OnInit, OnDestroy { directoryName = directoryName || ''; this.galleryService.loadDirectory(directoryName); - } + }; private onContentChange = (content: ContentWrapper): void => { const tmp = (content.searchResult || content.directory || { @@ -153,7 +158,7 @@ export class GalleryComponent implements OnInit, OnDestroy { break; } } - } + }; private sortDirectories(): void { if (!this.directories) { diff --git a/src/frontend/app/ui/gallery/share/share.gallery.component.html b/src/frontend/app/ui/gallery/share/share.gallery.component.html index a15a8a99..4b466926 100644 --- a/src/frontend/app/ui/gallery/share/share.gallery.component.html +++ b/src/frontend/app/ui/gallery/share/share.gallery.component.html @@ -49,7 +49,7 @@