refactor(ui/player): connect notes

This commit is contained in:
sylenien 2022-11-28 11:36:23 +01:00
parent 5e89bbbbb6
commit 2662b97401
3 changed files with 5 additions and 10 deletions

View file

@ -41,12 +41,9 @@ function WebPlayer(props: any) {
);
setContextValue({ player: WebPlayerInst, store: PlayerStore });
// initPlayer(session, jwt); TODOPlayer
props.fetchMembers();
notesStore.fetchSessionNotes(session.sessionId).then((r) => {
// WebPlayerInst.injectNotes(r);
// PlayerStore.update({ notes: r })
const note = props.query.get('note');
if (note) {
WebPlayerInst.pause();

View file

@ -10,6 +10,7 @@ import { debounce } from 'App/utils';
import TooltipContainer from './components/TooltipContainer';
import { PlayerContext } from 'App/components/Session/playerContext';
import { observer } from 'mobx-react-lite';
import { useStore } from 'App/mstore';
const BOUNDRY = 0;
@ -26,6 +27,7 @@ let debounceTooltipChange = () => null;
function Timeline(props) {
const { player, store } = React.useContext(PlayerContext)
const [wasPlaying, setWasPlaying] = React.useState(false);
const { notesStore } = useStore();
const {
playing,
time,
@ -36,8 +38,8 @@ function Timeline(props) {
disabled,
endTime,
live,
notes = [],
} = store.get()
const notes = notesStore.sessionNotes
const progressRef = React.useRef();
const timelineRef = React.useRef();

View file

@ -2,13 +2,9 @@ import { makeAutoObservable } from "mobx"
import { notesService } from "App/services"
import { Note, WriteNote, iTag, NotesFilter } from 'App/services/NotesService'
interface SessionNotes {
[sessionId: string]: Note[]
}
export default class NotesStore {
notes: Note[] = []
sessionNotes: SessionNotes = {}
sessionNotes: Note[] = []
loading: boolean
page = 1
pageSize = 10
@ -48,7 +44,7 @@ export default class NotesStore {
this.loading = true
try {
const notes = await notesService.getNotesBySessionId(sessionId)
this.sessionNotes[sessionId] = notes
this.sessionNotes = notes
return notes;
} catch (e) {
console.error(e)