import { select as e, delay as r, put as l } from "redux-saga/effects"
import {
clearAllFilesHandler as i,
updateFileEntryClearedAllStatus as o,
CLEAR_ALL_STATUS as d,
} from "../../media/file"
import { getAppCurrentRoomId as a, setIsClearingOldFiles as t } from "../app.reducer"
import { apiCall as p } from "../../../api/core"
import { getCoreBackend as m } from "../../../backend"
import { NOTIFICATION_CODE as c, userCustomNotification as f } from "../../notification"
import { taskErrorSaga as n } from "../../error"
export function* appClearAllFilesHandler({ payload: { roomId: t } }) {
const p = yield e(a)
;(yield i(t, p), yield r(500), yield l(o(d.INITIAL)))
}
export function* appClearOldFilesHandler() {
try {
const e = m()
yield l(t(!0))
const { bytesCleared: r } = yield p(e.clearOldFiles)
yield l(f({ code: c.OLD_FILES_CLEARED, bytesCleared: r }))
} catch (e) {
yield n("clearOldFilesHandler", e)
} finally {
yield l(t(!1))
}
}