import { takeEvery as e, takeLeading as i, select as l, put as o } from "redux-saga/effects"
import { isVideoMimeType as t } from "../../../lib/file"
import { callJoinCmd as f, getCallIsOngoing as r } from "../../../call"
import { getFilePlayerPlaying as d, getFileEntryById as m } from "../file.reducer"
import {
setFileViewer as a,
setFileViewerHighResolution as p,
toggleFilePlayer as y,
closeFilePlayer as n,
} from "../file.action"
export function* desktopFileMediaManagerSaga() {
;(yield i(a, function* ({ payload: { file: e } }) {
let i
if (e.fileId) {
const t = yield l(m, e.fileId)
;(t.preview?.large?.httpLink || (yield o(p(!0))), (i = t.mimetype))
} else i = e.mimetype
t(i) && (yield l(d)) && (yield o(y(!1)))
}),
yield e(f, function* () {
const e = yield l(r),
i = yield l(d)
e && i && (yield o(n()))
}))
}