Skip to content

Commit

Permalink
Add ability to toggle H on touch devices (#2674)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria authored Nov 12, 2024
1 parent ad9e3c1 commit bbdd883
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 13 additions & 1 deletion resources/js/components/headers/AlbumsHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import AlbumCreateTagDialog from "@/components/forms/album/AlbumCreateTagDialog.
import { computed, ComputedRef, ref } from "vue";
import { onKeyStroke } from "@vueuse/core";
import { useLycheeStateStore } from "@/stores/LycheeState";
import { shouldIgnoreKeystroke } from "@/utils/keybindings-utils";
import { isTouchDevice, shouldIgnoreKeystroke } from "@/utils/keybindings-utils";
import { storeToRefs } from "pinia";
import BackLinkButton from "./BackLinkButton.vue";
import { useContextMenuAlbumsAdd } from "@/composables/contextMenus/contextMenuAlbumsAdd";
Expand Down Expand Up @@ -284,6 +284,18 @@ const menu = computed(() =>
callback: openAddMenu,
if: props.rights.can_upload,
},
{
icon: "pi pi-eye-slash",
type: "fn",
callback: () => (lycheeStore.are_nsfw_visible = false),
if: isTouchDevice() && lycheeStore.are_nsfw_visible,
},
{
icon: "pi pi-eye",
type: "fn",
callback: () => (lycheeStore.are_nsfw_visible = true),
if: isTouchDevice() && !lycheeStore.are_nsfw_visible,
},
].filter((item) => item.if),
) as ComputedRef<MenuRight[]>;
Expand Down
4 changes: 4 additions & 0 deletions resources/js/utils/keybindings-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ export function disableCtrlA(): void {
false,
);
}

export function isTouchDevice(): boolean {
return "ontouchstart" in document.documentElement || navigator.maxTouchPoints > 0;
}

0 comments on commit bbdd883

Please sign in to comment.