diff --git a/src/admin/AdminAppMenu.tsx b/src/admin/AdminAppMenu.tsx
index 4336b82b..1835ea05 100644
--- a/src/admin/AdminAppMenu.tsx
+++ b/src/admin/AdminAppMenu.tsx
@@ -1,8 +1,7 @@
'use client';
import MoreMenu from '@/components/more/MoreMenu';
-import { GRID_HOMEPAGE_ENABLED } from '@/site/config';
-import { PATH_ADMIN_CONFIGURATION, PATH_GRID, PATH_ROOT } from '@/site/paths';
+import { PATH_ADMIN_CONFIGURATION, PATH_GRID_INFERRED } from '@/site/paths';
import { useAppState } from '@/state/AppState';
import { BiCog } from 'react-icons/bi';
import { ImCheckboxUnchecked } from 'react-icons/im';
@@ -33,7 +32,7 @@ export default function AdminAppMenu() {
: ,
- href: GRID_HOMEPAGE_ENABLED ? PATH_ROOT : PATH_GRID,
+ href: PATH_GRID_INFERRED,
action: () => {
if (isSelecting) {
setSelectedPhotoIds?.(undefined);
diff --git a/src/admin/AdminBatchEditPanelClient.tsx b/src/admin/AdminBatchEditPanelClient.tsx
index b3b98b35..5e0e2f8a 100644
--- a/src/admin/AdminBatchEditPanelClient.tsx
+++ b/src/admin/AdminBatchEditPanelClient.tsx
@@ -10,12 +10,16 @@ import DeleteButton from './DeleteButton';
import { useState } from 'react';
import TagInput from '@/components/TagInput';
import { convertTagsForForm, Tags } from '@/tag';
+import { usePathname } from 'next/navigation';
+import { PATH_GRID_INFERRED } from '@/site/paths';
export default function AdminBatchEditPanelClient({
existingTags,
}: {
existingTags: Tags
}) {
+ const pathname = usePathname();
+
const {
isUserSignedIn,
selectedPhotoIds,
@@ -62,7 +66,11 @@ export default function AdminBatchEditPanelClient({
/>
>;
- return isUserSignedIn && selectedPhotoIds !== undefined
+ return (
+ isUserSignedIn &&
+ pathname === PATH_GRID_INFERRED &&
+ selectedPhotoIds !== undefined
+ )
? ,
- items: ([{
- label: 'Home',
- path: '/',
- }, {
- label: 'Grid',
- path:'/grid',
- }]),
+ items: pagesItems,
};
const adminSection: CommandKSection = {
@@ -278,6 +297,17 @@ export default function CommandKClient({
label: 'App Config',
annotation: ,
path: PATH_ADMIN_CONFIGURATION,
+ }, {
+ label: selectedPhotoIds === undefined
+ ? 'Select Multiple Photos'
+ : 'Exit Select Multiple Photos',
+ annotation: ,
+ path: selectedPhotoIds === undefined
+ ? PATH_GRID_INFERRED
+ : undefined,
+ action: selectedPhotoIds === undefined
+ ? () => setSelectedPhotoIds?.([])
+ : () => setSelectedPhotoIds?.(undefined),
}] as CommandKItem[])
.concat(showDebugTools
? [{
@@ -393,15 +423,20 @@ export default function CommandKClient({
value={key}
keywords={keywords}
onSelect={() => {
+ if (action) {
+ action();
+ if (!path) { setIsOpen?.(false); }
+ }
if (path) {
- setKeyPending(key);
- startTransition(async () => {
- shouldCloseAfterPending.current = true;
- router.push(path, { scroll: true });
- });
- } else {
- setIsOpen?.(false);
- action?.();
+ if (path !== pathname) {
+ setKeyPending(key);
+ startTransition(async () => {
+ shouldCloseAfterPending.current = true;
+ router.push(path, { scroll: true });
+ });
+ } else {
+ setIsOpen?.(false);
+ }
}
}}
accessory={accessory}
diff --git a/src/site/ViewSwitcher.tsx b/src/site/ViewSwitcher.tsx
index 1099b7ff..3d5a2baf 100644
--- a/src/site/ViewSwitcher.tsx
+++ b/src/site/ViewSwitcher.tsx
@@ -4,9 +4,8 @@ import IconFeed from '@/site/IconFeed';
import IconGrid from '@/site/IconGrid';
import {
PATH_ADMIN_PHOTOS,
- PATH_FEED,
- PATH_GRID,
- PATH_ROOT,
+ PATH_FEED_INFERRED,
+ PATH_GRID_INFERRED,
} from '@/site/paths';
import { BiLockAlt } from 'react-icons/bi';
import IconSearch from './IconSearch';
@@ -27,7 +26,7 @@ export default function ViewSwitcher({
const renderItemFeed = () =>
}
- href={GRID_HOMEPAGE_ENABLED ? PATH_FEED : PATH_ROOT}
+ href={PATH_FEED_INFERRED}
active={currentSelection === 'feed'}
noPadding
/>;
@@ -35,7 +34,7 @@ export default function ViewSwitcher({
const renderItemGrid = () =>
}
- href={GRID_HOMEPAGE_ENABLED ? PATH_ROOT : PATH_GRID}
+ href={PATH_GRID_INFERRED}
active={currentSelection === 'grid'}
noPadding
/>;
diff --git a/src/site/paths.ts b/src/site/paths.ts
index 53053912..8d15811d 100644
--- a/src/site/paths.ts
+++ b/src/site/paths.ts
@@ -1,5 +1,5 @@
import { Photo } from '@/photo';
-import { BASE_URL } from './config';
+import { BASE_URL, GRID_HOMEPAGE_ENABLED } from './config';
import { Camera } from '@/camera';
import { FilmSimulation } from '@/simulation';
import { parameterize } from '@/utility/string';
@@ -13,6 +13,10 @@ export const PATH_ADMIN = '/admin';
export const PATH_API = '/api';
export const PATH_SIGN_IN = '/sign-in';
export const PATH_OG = '/og';
+// eslint-disable-next-line max-len
+export const PATH_GRID_INFERRED = GRID_HOMEPAGE_ENABLED ? PATH_ROOT : PATH_GRID;
+// eslint-disable-next-line max-len
+export const PATH_FEED_INFERRED = GRID_HOMEPAGE_ENABLED ? PATH_FEED : PATH_ROOT;
// Path prefixes
export const PREFIX_PHOTO = '/p';