);
}
export function addToAlbumPicker(ids: MediaId[]) {
if (!ids.length) return;
openModal();
}
/** Move items out of `fromAlbumId` into a chosen album. */
export function moveToAlbumPicker(fromAlbumId: string, ids: MediaId[]) {
if (!ids.length) return;
openModal();
}
/* ----------------------------- Confirm dialog ----------------------------- */
export function confirmAction(opts: {
title: string;
message: string;
confirmLabel?: string;
danger?: boolean;
onConfirm: () => void;
}) {
openModal(
{opts.title}
{opts.message}
,
);
}
/* ----------------------------- Security (lock) settings ----------------------------- */
function SecuritySettingsModal() {
const api = useGalleryStoreApi();
const hasPw = useGallery((s) => s.lockConfigured);
// A server-backed lock reads/writes the host's backend, not this device.
const serverBacked = useGallery((s) => Boolean(s.config.lockProvider));
const [p1, setP1] = useState('');
const [p2, setP2] = useState('');
const [err, setErr] = useState(null);
const [busy, setBusy] = useState(false);
const save = async () => {
if (p1.trim().length < 4) return setErr('Use at least 4 characters.');
if (p1 !== p2) return setErr('Passwords do not match.');
setBusy(true);
const state = api.getState();
state.clearLockError();
await state.setLockPassword(p1.trim());
setBusy(false);
// The store reports an unreachable provider rather than throwing.
if (api.getState().lockError === 'unavailable') {
setErr("Couldn't reach the server. Try again.");
return;
}
closeModal();
};
const remove = async () => {
setBusy(true);
const state = api.getState();
state.clearLockError();
await state.removeLockPassword();
setBusy(false);
if (api.getState().lockError === 'unavailable') {
setErr("Couldn't reach the server. Try again.");
return;
}
closeModal();
};
return (
{hasPw ? 'Recently Deleted is Locked' : 'Lock Recently Deleted'}
{serverBacked
? hasPw
? 'Set a new password, or remove the lock. It applies to your account on every device.'
: 'Protect Recently Deleted with a password. It applies to your account on every device.'
: hasPw
? 'Set a new password, or remove the lock. The password is stored only on this device.'
: 'Protect Recently Deleted with a password. It is stored only on this device (not uploaded).'}
“{created.title}” — anyone with this link can view {created.mediaIds.length} item
{created.mediaIds.length === 1 ? '' : 's'}.
e.currentTarget.select()} />
);
}
return (
Share
{selectionIds.length > 0 ? (
) : null}
Or share album{albums.length === 1 ? '' : 's'} (tick one or more):
{albums.map((a) => (
))}
{albums.length === 0 ? (
No albums yet.
) : null}
);
}
/** Open the Share modal. Pass selected media ids and/or the current album id. */
export function openShareModal(selectionIds: MediaId[] = [], albumId?: AlbumId) {
openModal();
}