Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Handle both cases

Manav Rathi54da18125651
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index e9452c163d..f2345ebdfe 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -55,9 +55,9 @@ import { useCallback, useEffect, useMemo, useState } from "react";
import { resumeExportsIfNeeded } from "services/export";
import { photosLogout } from "services/logout";
-// import "photoswipe/dist/photoswipe.css";
+import "photoswipe/dist/photoswipe.css";
// TODO(PS): Note, auto hide only works with the new CSS.
-import "../../../../packages/new/photos/components/ps5/dist/photoswipe.css";
+// import "../../../../packages/new/photos/components/ps5/dist/photoswipe.css";
import "styles/global.css";
diff --git a/web/packages/new/photos/components/FileViewerPhotoSwipe.ts b/web/packages/new/photos/components/FileViewerPhotoSwipe.ts
index 0956f7d9cb..83b1ca23ea 100644
--- a/web/packages/new/photos/components/FileViewerPhotoSwipe.ts
+++ b/web/packages/new/photos/components/FileViewerPhotoSwipe.ts
@@ -136,9 +136,14 @@ export class FileViewerPhotoSwipe {
* {@link autoHideCheckIntervalId} to implement the auto hiding of controls
* when the user stops moving the pointer for a while.
*
- * This will be "hidden" if controls have already been hidden.
+ * Apart from a date, this can also be:
+ *
+ * - "already-hidden" if controls have already been hidden, say by a
+ * bgClickAction.
+ *
+ * - "auto-hidden" if controls were hidden by us because of inactivity.
*/
- private lastActivityDate: Date | "hidden";
+ private lastActivityDate: Date | "auto-hidden" | "already-hidden";
constructor({
files,
@@ -221,7 +226,8 @@ export class FileViewerPhotoSwipe {
log.debug(() => ["[ps]", { itemData, index, file, itemData }]);
if (!file) assertionFailed();
- this.lastActivityDate = new Date();
+ if (this.lastActivityDate != "already-hidden")
+ this.lastActivityDate = new Date();
return itemData ?? {};
});
@@ -234,11 +240,6 @@ export class FileViewerPhotoSwipe {
return originalResult;
});
- // TODO(PS): Fix interaction between click hide and auto hide.
- // pswp.on("bgClickAction", () => {
- // this.lastActivityDate == "hidden";
- // });
-
pswp.on("contentLoad", (e) => {
console.log("contentLoad", e);
if (e.content.data.videoURL) {
@@ -312,18 +313,28 @@ export class FileViewerPhotoSwipe {
}
private onPointerActivity() {
- if (this.lastActivityDate == "hidden") this.showUIControls();
+ if (this.lastActivityDate == "already-hidden") return;
+ if (this.lastActivityDate == "auto-hidden") this.showUIControls();
this.lastActivityDate = new Date();
}
private autoHideIfInactive() {
- if (this.lastActivityDate == "hidden") return;
+ if (this.lastActivityDate == "already-hidden") return;
+ if (this.lastActivityDate == "auto-hidden") return;
if (Date.now() - this.lastActivityDate.getTime() > 3000) {
- this.hideUIControls();
- this.lastActivityDate = "hidden";
+ if (this.areUIControlsVisible()) {
+ this.hideUIControls();
+ this.lastActivityDate = "auto-hidden";
+ } else {
+ this.lastActivityDate = "already-hidden";
+ }
}
}
+ private areUIControlsVisible() {
+ return this.pswp.element.classList.contains("pswp--ui-visible");
+ }
+
private showUIControls() {
this.pswp.element.classList.add("pswp--ui-visible");
}