Skip to content

Commit 36546c2

Browse files
authored
The eye does nothing if there are no hidden albums (#2857)
* The eye does nothing if there are no hidden albums, so better hide it to avoid confusing users
1 parent 1856646 commit 36546c2

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

resources/js/components/gallery/AlbumHero.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@
5959
>
6060
<i class="pi pi-chart-scatter" />
6161
</a>
62+
<template v-if="isTouchDevice() && user?.id !== null">
63+
<a
64+
v-if="props.hasHidden && lycheeStore.are_nsfw_visible"
65+
class="flex-shrink-0 px-3 cursor-pointer text-muted-color inline-block transform duration-300 hover:scale-150 hover:text-color"
66+
:title="'hide hidden'"
67+
@click="lycheeStore.are_nsfw_visible = false"
68+
>
69+
<i class="pi pi pi-eye-slash" />
70+
</a>
71+
<a
72+
v-if="props.hasHidden && !lycheeStore.are_nsfw_visible"
73+
class="flex-shrink-0 px-3 cursor-pointer text-muted-color inline-block transform duration-300 hover:scale-150 hover:text-color"
74+
:title="'show hidden'"
75+
@click="lycheeStore.are_nsfw_visible = true"
76+
>
77+
<i class="pi pi-eye" />
78+
</a>
79+
</template>
6280
</div>
6381
<div
6482
v-if="props.album.preFormattedData.description"
@@ -72,16 +90,18 @@
7290
import AlbumService from "@/services/album-service";
7391
import { useAuthStore } from "@/stores/Auth";
7492
import { useLycheeStateStore } from "@/stores/LycheeState";
93+
import { isTouchDevice } from "@/utils/keybindings-utils";
7594
import { storeToRefs } from "pinia";
7695
import Card from "primevue/card";
7796
7897
const auth = useAuthStore();
7998
const lycheeStore = useLycheeStateStore();
80-
const { is_se_enabled, is_se_preview_enabled } = storeToRefs(lycheeStore);
99+
const { is_se_enabled, is_se_preview_enabled, are_nsfw_visible } = storeToRefs(lycheeStore);
81100
const { user } = storeToRefs(auth);
82101
83102
const props = defineProps<{
84103
album: App.Http.Resources.Models.AlbumResource | App.Http.Resources.Models.TagAlbumResource | App.Http.Resources.Models.SmartAlbumResource;
104+
hasHidden: boolean;
85105
}>();
86106
87107
const emits = defineEmits<{

resources/js/components/headers/AlbumsHeader.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const props = defineProps<{
112112
back_button_url: string;
113113
login_button_position: string;
114114
};
115+
hasHidden: boolean;
115116
}>();
116117
117118
const emits = defineEmits<{
@@ -279,13 +280,13 @@ const menu = computed(() =>
279280
icon: "pi pi-eye-slash",
280281
type: "fn",
281282
callback: () => (lycheeStore.are_nsfw_visible = false),
282-
if: isTouchDevice() && lycheeStore.are_nsfw_visible,
283+
if: isTouchDevice() && props.hasHidden && lycheeStore.are_nsfw_visible,
283284
},
284285
{
285286
icon: "pi pi-eye",
286287
type: "fn",
287288
callback: () => (lycheeStore.are_nsfw_visible = true),
288-
if: isTouchDevice() && !lycheeStore.are_nsfw_visible,
289+
if: isTouchDevice() && props.hasHidden && !lycheeStore.are_nsfw_visible,
289290
},
290291
].filter((item) => item.if),
291292
) as ComputedRef<MenuRight[]>;

resources/js/composables/album/albumRefresher.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export function useAlbumRefresher(albumId: Ref<string>, auth: AuthStore, isLogin
1111
const smartAlbum = ref<App.Http.Resources.Models.SmartAlbumResource | undefined>(undefined);
1212
const album = computed(() => modelAlbum.value || tagAlbum.value || smartAlbum.value);
1313
const isAlbumConsented = ref(false);
14+
const hasHidden = computed(() => modelAlbum.value !== undefined && modelAlbum.value.albums.filter((album) => album.is_nsfw).length > 0);
1415

1516
const photos = ref<App.Http.Resources.Models.PhotoResource[]>([]);
1617
const config = ref<App.Http.Resources.GalleryConfigs.AlbumConfig | undefined>(undefined);
@@ -76,6 +77,7 @@ export function useAlbumRefresher(albumId: Ref<string>, auth: AuthStore, isLogin
7677
rights,
7778
photos,
7879
config,
80+
hasHidden,
7981
loadUser,
8082
loadAlbum,
8183
refresh,

resources/js/composables/album/albumsRefresher.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function useAlbumsRefresher(auth: AuthStore, lycheeStore: LycheeStateStor
1515
const rootConfig = ref<App.Http.Resources.GalleryConfigs.RootConfig | undefined>(undefined);
1616
const rootRights = ref<App.Http.Resources.Rights.RootAlbumRightsResource | undefined>(undefined);
1717
const selectableAlbums = computed(() => albums.value.concat(sharedAlbums.value.map((album) => album.data).flat()));
18+
const hasHidden = computed(() => selectableAlbums.value.filter((album) => album.is_nsfw).length > 0);
1819

1920
function refresh(): Promise<[void, void]> {
2021
isLoading.value = true;
@@ -73,6 +74,7 @@ export function useAlbumsRefresher(auth: AuthStore, lycheeStore: LycheeStateStor
7374
rootConfig,
7475
rootRights,
7576
selectableAlbums,
77+
hasHidden,
7678
refresh,
7779
};
7880
}

resources/js/views/gallery-panels/Album.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@
3939
>{{ $t("lychee.UPLOAD_PHOTO") }}</Button
4040
>
4141
</div>
42-
<AlbumHero v-if="!noData" :album="album" @open-sharing-modal="toggleShareAlbum" @open-statistics="toggleStatistics" />
42+
<AlbumHero
43+
v-if="!noData"
44+
:album="album"
45+
:has-hidden="hasHidden"
46+
@open-sharing-modal="toggleShareAlbum"
47+
@open-statistics="toggleStatistics"
48+
/>
4349
<template v-if="is_se_enabled && user?.id !== null">
4450
<AlbumStatistics
4551
:photos="photos"
@@ -249,7 +255,7 @@ function toggleSlideShow() {
249255
const { layoutConfig, loadLayoutConfig } = useGetLayoutConfig();
250256
251257
// Set up Album ID reference. This one is updated at each page change.
252-
const { isAlbumConsented, isPasswordProtected, isLoading, user, modelAlbum, album, rights, photos, config, refresh } = useAlbumRefresher(
258+
const { isAlbumConsented, isPasswordProtected, isLoading, user, modelAlbum, album, rights, photos, config, hasHidden, refresh } = useAlbumRefresher(
253259
albumid,
254260
auth,
255261
is_login_open,

resources/js/views/gallery-panels/Albums.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
@refresh="refresh"
1818
@help="isKeybindingsHelpOpen = true"
1919
:config="rootConfig"
20+
:has-hidden="hasHidden"
2021
/>
2122
</Collapse>
2223
<AlbumThumbPanel
@@ -177,7 +178,7 @@ const { are_nsfw_visible, title } = storeToRefs(lycheeStore);
177178
178179
const photos = ref([]); // unused.
179180
180-
const { user, isLoading, isKeybindingsHelpOpen, smartAlbums, albums, sharedAlbums, rootConfig, rootRights, selectableAlbums, refresh } =
181+
const { user, isLoading, isKeybindingsHelpOpen, smartAlbums, albums, sharedAlbums, rootConfig, rootRights, selectableAlbums, hasHidden, refresh } =
181182
useAlbumsRefresher(auth, lycheeStore, is_login_open);
182183
183184
const { selectedAlbum, selectedAlbumsIdx, selectedAlbums, selectedAlbumsIds, albumClick, selectEverything, unselect, hasSelection } = useSelection(

0 commit comments

Comments
 (0)