Skip to content

armgit / ente

Public Imported from GitHub
0

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

close

Manav Rathi719c5584f79f
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index eb7965482f..df8e9947a0 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -536,6 +536,7 @@ export class FileViewerPhotoSwipe {
// Hide the auto option
qualityMenu.radioGroupItems[0]!.hidden = true;
} else {
+ qualityMenu.radioGroupItems[0]!.hidden = false;
const value =
videoQualityForFileID(fileID) == "auto"
? pt("Auto")
@@ -550,6 +551,41 @@ export class FileViewerPhotoSwipe {
}
};
+ /**
+ * Toggle the settings menu by activating the menu button.
+ *
+ * This should be more robust than us trying to reverse engineer the
+ * internal media chrome logic to open and close the menu. However, the
+ * caveat is that this will only work for closing the menu (our goal)
+ * if the menu is already open.
+ */
+ const toggleMediaChromeSettingsMenu = () => {
+ const menuButton = document.querySelector(
+ "media-settings-menu-button",
+ );
+ if (menuButton instanceof MediaChromeMenuButton) {
+ menuButton.handleClick();
+
+ // See: [Note: Media chrome focus workaround]
+ //
+ // Whatever media chrome is doing internally, it requires us to
+ // drop the focus multiple times (Removing either of these calls
+ // is not enough).
+ const blurAllFocused = () =>
+ document
+ .querySelectorAll(":focus")
+ .forEach((e) => e instanceof HTMLElement && e.blur());
+
+ blurAllFocused();
+ setTimeout(blurAllFocused, 0);
+ }
+ };
+
+ const closeMediaChromeSettingsMenuIfOpen = () => {
+ if (document.querySelector("media-settings-menu:not([hidden])"))
+ toggleMediaChromeSettingsMenu();
+ };
+
pswp.on("contentAppend", (e) => {
// PhotoSwipe emits stale contentAppend events. e.g. when changing
// the video quality, we'll first get "contentAppend" (and "change")
@@ -678,6 +714,8 @@ export class FileViewerPhotoSwipe {
() => void updateFileInfoExifIfNeeded(currSlideData()),
);
+ pswp.on("change", closeMediaChromeSettingsMenuIfOpen);
+
pswp.on("contentDestroy", (e) =>
forgetExifForItemData(asItemData(e.content.data)),
);
@@ -849,36 +887,6 @@ export class FileViewerPhotoSwipe {
if (currentFileAnnotation().showDownload) handleDownload();
};
- /**
- * Toggle the settings menu by activating the menu button.
- *
- * This should be more robust than us trying to reverse engineer the
- * internal media chrome logic to open and close the menu. However, the
- * caveat is that this will only work for closing the menu (our goal)
- * if the menu is already open.
- */
- const toggleMediaChromeSettingsMenu = () => {
- const menuButton = document.querySelector(
- "media-settings-menu-button",
- );
- if (menuButton instanceof MediaChromeMenuButton) {
- menuButton.handleClick();
-
- // See: [Note: Media chrome focus workaround]
- //
- // Whatever media chrome is doing internally, it requires us to
- // drop the focus multiple times (Removing either of these calls
- // is not enough).
- const blurAllFocused = () =>
- document
- .querySelectorAll(":focus")
- .forEach((e) => e instanceof HTMLElement && e.blur());
-
- blurAllFocused();
- setTimeout(blurAllFocused, 0);
- }
- };
-
const onVideoQualityChange = () => {
if (shouldIgnoreNextVideoQualityChange) {
// Ignore changes that we ourselves initiated on slide change.