mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 08:54:13 +00:00
fix: undo changes
This commit is contained in:
parent
81f33d9d37
commit
32da26ccfc
1 changed files with 13 additions and 54 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { useMemo, useEffect, useRef } from 'react';
|
import { useMemo, useEffect } from 'react';
|
||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
import { BiSolidHeart } from 'react-icons/bi/index';
|
import { BiSolidHeart } from 'react-icons/bi/index';
|
||||||
import { Howler } from 'howler';
|
import { Howler } from 'howler';
|
||||||
|
|
@ -19,14 +19,9 @@ import { sounds } from '@/data/sounds';
|
||||||
import type { Sound } from '@/data/types';
|
import type { Sound } from '@/data/types';
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
const audio = useRef<HTMLAudioElement | null>(null);
|
|
||||||
|
|
||||||
const categories = useMemo(() => sounds.categories, []);
|
const categories = useMemo(() => sounds.categories, []);
|
||||||
|
|
||||||
const favorites = useSoundStore(useShallow(state => state.getFavorites()));
|
const favorites = useSoundStore(useShallow(state => state.getFavorites()));
|
||||||
const play = useSoundStore(state => state.play);
|
|
||||||
const pause = useSoundStore(state => state.pause);
|
|
||||||
const isPlaying = useSoundStore(state => state.isPlaying);
|
|
||||||
|
|
||||||
const favoriteSounds = useMemo(() => {
|
const favoriteSounds = useMemo(() => {
|
||||||
const favoriteSounds = categories
|
const favoriteSounds = categories
|
||||||
|
|
@ -58,38 +53,6 @@ export function App() {
|
||||||
return () => document.removeEventListener('visibilitychange', onChange);
|
return () => document.removeEventListener('visibilitychange', onChange);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (audio.current) {
|
|
||||||
const { ctx } = Howler;
|
|
||||||
const dest = ctx.createMediaStreamDestination();
|
|
||||||
audio.current.srcObject = dest.stream;
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
try {
|
|
||||||
navigator.mediaSession.setActionHandler('play', play);
|
|
||||||
navigator.mediaSession.setActionHandler('pause', pause);
|
|
||||||
navigator.mediaSession.setActionHandler('stop', pause);
|
|
||||||
} catch (error) {
|
|
||||||
console.log('Media session is no supported yet');
|
|
||||||
}
|
|
||||||
}, [play, pause]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isPlaying) {
|
|
||||||
navigator.mediaSession.metadata = new MediaMetadata({
|
|
||||||
title: 'Moodist',
|
|
||||||
});
|
|
||||||
|
|
||||||
audio.current?.play();
|
|
||||||
navigator.mediaSession.playbackState = 'playing';
|
|
||||||
} else {
|
|
||||||
audio.current?.pause();
|
|
||||||
navigator.mediaSession.playbackState = 'paused';
|
|
||||||
}
|
|
||||||
}, [isPlaying]);
|
|
||||||
|
|
||||||
const allCategories = useMemo(() => {
|
const allCategories = useMemo(() => {
|
||||||
const favorites = [];
|
const favorites = [];
|
||||||
|
|
||||||
|
|
@ -106,22 +69,18 @@ export function App() {
|
||||||
}, [favoriteSounds, categories]);
|
}, [favoriteSounds, categories]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<SnackbarProvider>
|
||||||
<SnackbarProvider>
|
<StoreConsumer>
|
||||||
<StoreConsumer>
|
<Container>
|
||||||
<Container>
|
<div id="app" />
|
||||||
<div id="app" />
|
<Buttons />
|
||||||
<Buttons />
|
<Categories categories={allCategories} />
|
||||||
<Categories categories={allCategories} />
|
</Container>
|
||||||
</Container>
|
|
||||||
|
|
||||||
<ScrollToTop />
|
<ScrollToTop />
|
||||||
<Menu />
|
<Menu />
|
||||||
<SharedModal />
|
<SharedModal />
|
||||||
</StoreConsumer>
|
</StoreConsumer>
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
|
|
||||||
<audio aria-hidden={true} ref={audio} src="" />
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue