import { api } from "../../../api"
import { mediaLibrary } from "../../store"

export async function loadLibraryAndSetStore(): Promise<null> {
    const libraryRes = await api<MediaLibrary[]>("medialib", {})
    const libStore: { [id: string]: MediaLibrary } = {}
    libraryRes.data.forEach((el: MediaLibrary) => {
        libStore[el.id] = el
    })
    mediaLibrary.set(libStore)
    return null
}
