collection drawer ui fix
This commit is contained in:
@@ -33,6 +33,31 @@ import { useSharePost } from "@/components/social/share-post-provider";
|
||||
const MAX_IMAGES = 5;
|
||||
const PRESS_IMAGE_TYPES = "image/png,image/jpeg,image/webp,image/gif";
|
||||
|
||||
// Lazy-init singleton for the success chime. The user clicked "Post"
|
||||
// to get here, so we're inside an active user-gesture context — modern
|
||||
// browsers (incl. iOS Safari) honour audio playback on that activation.
|
||||
// Anything that goes wrong (autoplay policy, decode failure, the file
|
||||
// not yet cached on first run) falls through silently; the visible
|
||||
// toast already communicates success, the sound is icing.
|
||||
let successAudio: HTMLAudioElement | null = null;
|
||||
function playSuccessSound() {
|
||||
if (typeof window === "undefined") return;
|
||||
try {
|
||||
if (!successAudio) {
|
||||
successAudio = new Audio("/audio/success.mp3");
|
||||
successAudio.preload = "auto";
|
||||
}
|
||||
// Reset so rapid posts get a fresh chime instead of being
|
||||
// ignored as "already playing".
|
||||
successAudio.currentTime = 0;
|
||||
void successAudio.play().catch(() => {
|
||||
// Silent — see comment above.
|
||||
});
|
||||
} catch {
|
||||
// Audio constructor unavailable or quota'd — silent.
|
||||
}
|
||||
}
|
||||
|
||||
export function ComposePost({
|
||||
open,
|
||||
onClose,
|
||||
@@ -128,6 +153,7 @@ export function ComposePost({
|
||||
onPosted?.();
|
||||
onClose();
|
||||
router.refresh();
|
||||
playSuccessSound();
|
||||
// Success feedback + offer to externally share. The BFF's Create
|
||||
// response doesn't include author info (no JOIN with users), but
|
||||
// SharePostSheet falls back to the authed user's handle when
|
||||
|
||||
Reference in New Issue
Block a user