Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove the auto hide code, it is too distracting to enable

Manav Rathi3211e6afe6d2
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsx
index 2443ca8a30..cdd5d951c6 100644
--- a/web/packages/gallery/components/FileInfo.tsx
+++ b/web/packages/gallery/components/FileInfo.tsx
@@ -6,7 +6,6 @@
- photos/FileInfo
*/
-import { assertionFailed } from "@/base/assert";
import { LinkButtonUndecorated } from "@/base/components/LinkButton";
import { type ButtonishProps } from "@/base/components/mui";
import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator";
@@ -207,14 +206,13 @@ export const FileInfo: React.FC<FileInfoProps> = ({
const location = useMemo(
// Prefer the location in the EnteFile, then fall back to Exif.
- () => (file ? fileLocation(file) : undefined) ?? exif?.parsed?.location,
+ () => fileLocation(file) ?? exif?.parsed?.location,
[file, exif],
);
const annotatedExif = useMemo(() => annotateExif(exif), [exif]);
useEffect(() => {
- if (!file) return;
if (!isMLEnabled()) return;
let didCancel = false;
@@ -529,11 +527,8 @@ const EditButton: React.FC<EditButtonProps> = ({ onClick, loading }) => (
type CaptionProps = Pick<
FileInfoProps,
- "allowEdits" | "onNeedsRemoteSync" | "onUpdateCaption"
-> & {
- /* TODO(PS): This is DisplayFile, but that's meant to be removed */
- file: EnteFile & { title?: string };
-};
+ "file" | "allowEdits" | "onNeedsRemoteSync" | "onUpdateCaption"
+>;
const Caption: React.FC<CaptionProps> = ({
file,
@@ -557,8 +552,6 @@ const Caption: React.FC<CaptionProps> = ({
try {
const updatedFile = await changeCaption(file, newCaption);
updateExistingFilePubMetadata(file, updatedFile);
- // @ts-ignore
- file.title = file.pubMagicMetadata.data.caption;
onUpdateCaption(file);
} catch (e) {
log.error("Failed to update caption", e);
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index 34aafbae1d..a574399a53 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -271,48 +271,6 @@ export class FileViewerPhotoSwipe {
const currentFileAnnotation = () => currentAnnotatedFile().annotation;
- // Toggle controls infrastructure
-
- /**
- * An interval that invokes a periodic check of whether we should the hide
- * controls if the user does not perform any pointer events for a while.
- */
- let autoHideCheckIntervalID: ReturnType<typeof setTimeout> | undefined;
-
- /**
- * The time the last activity occurred. Used in tandem with
- * {@link autoHideCheckIntervalID} to implement the auto hiding of controls
- * when the user stops moving the pointer for a while.
- *
- * Apart from a date, this can also be:
- *
- * - "already-hidden" if controls have already been hidden, say by a
- * bgClickAction or our keyboard shortcut.
- *
- * - "auto-hidden" if controls were hidden by us because of inactivity.
- */
- let lastActivityDate: Date | "auto-hidden" | "already-hidden" =
- new Date();
-
- const areUIControlsVisible = () =>
- pswp.element.classList.contains("pswp--ui-visible");
- const showUIControls = () =>
- pswp.element.classList.add("pswp--ui-visible");
- const hideUIControls = () =>
- pswp.element.classList.remove("pswp--ui-visible");
- const toggleUIControls = () =>
- pswp.element.classList.toggle("pswp--ui-visible");
-
- // Return true if the current keyboard focus is on any of the UI
- // controls (e.g. as a result of user tabbing through them).
- const isFocusedOnUIControl = () => {
- const fv = document.querySelector(":focus-visible");
- if (fv && !fv.classList.contains("pswp")) {
- return true;
- }
- return false;
- };
-
// Provide data about slides to PhotoSwipe via callbacks
// https://photoswipe.com/data-sources/#dynamically-generated-data
@@ -334,9 +292,6 @@ export class FileViewerPhotoSwipe {
};
}
- if (lastActivityDate != "already-hidden")
- lastActivityDate = new Date();
-
return itemData;
});
@@ -348,16 +303,6 @@ export class FileViewerPhotoSwipe {
return content.data.isContentZoomable ?? isZoomable;
});
- pswp.addFilter("preventPointerEvent", (preventPointerEvent) => {
- // There was a pointer event. We don't care which one, we just use
- // this as a hook to show the UI again (if needed), and update our
- // last activity date.
- if (lastActivityDate == "auto-hidden") showUIControls();
- if (lastActivityDate != "already-hidden")
- lastActivityDate = new Date();
- return preventPointerEvent;
- });
-
/**
* Last state of the live photo playback toggle.
*/
@@ -614,10 +559,6 @@ export class FileViewerPhotoSwipe {
// The PhotoSwipe dialog has being closed and the animations have
// completed.
pswp.on("destroy", () => {
- if (autoHideCheckIntervalID) {
- clearInterval(autoHideCheckIntervalID);
- autoHideCheckIntervalID = undefined;
- }
fileViewerDidClose();
// Let our parent know that we have been closed.
onClose();
@@ -877,11 +818,6 @@ export class FileViewerPhotoSwipe {
// Actions we handle ourselves.
- const handleToggleUIControls = () => {
- toggleUIControls();
- lastActivityDate = new Date();
- };
-
const handleTogglePlayIfPossible = () => {
switch (currentAnnotatedFile().itemData.fileType) {
case FileType.video:
@@ -904,6 +840,21 @@ export class FileViewerPhotoSwipe {
}
};
+ // Toggle controls infrastructure
+
+ const handleToggleUIControls = () =>
+ pswp.element.classList.toggle("pswp--ui-visible");
+
+ // Return true if the current keyboard focus is on any of the UI
+ // controls (e.g. as a result of user tabbing through them).
+ const isFocusedOnUIControl = () => {
+ const fv = document.querySelector(":focus-visible");
+ if (fv && !fv.classList.contains("pswp")) {
+ return true;
+ }
+ return false;
+ };
+
// Some actions routed via the delegate
const handleDelete = () => delegate.performKeyAction("delete");
@@ -994,11 +945,6 @@ export class FileViewerPhotoSwipe {
}
cb?.();
-
- // Undo auto hide when the user presses tab to move focus.
- if (key == "Tab") {
- if (lastActivityDate == "auto-hidden") showUIControls();
- }
});
// Let our data source know that we're about to open.
@@ -1007,23 +953,6 @@ export class FileViewerPhotoSwipe {
// Initializing PhotoSwipe adds it to the DOM as a dialog-like div with
// the class "pswp".
pswp.init();
-
- autoHideCheckIntervalID = setInterval(() => {
- if (lastActivityDate == "already-hidden") return;
- if (lastActivityDate == "auto-hidden") return;
- // TODO(PS): Disable for now.
- return;
- if (Date.now() - lastActivityDate.getTime() > 9000 /* ~10s */) {
- if (areUIControlsVisible()) {
- if (!isFocusedOnUIControl()) {
- hideUIControls();
- lastActivityDate = "auto-hidden";
- }
- } else {
- lastActivityDate = "already-hidden";
- }
- }
- }, 3000);
}
/**