Update asset live query to use bulkGet to fix crash on private browsing Firefox

This commit is contained in:
Mitchell McCaffrey 2021-07-23 18:51:51 +10:00
parent 3aace97004
commit fdefd907e3

View File

@ -160,7 +160,7 @@ export function AssetURLsProvider({ children }) {
// Get the new assets whenever the keys change
const assets = useLiveQuery(
() => database?.table("assets").where("id").anyOf(assetKeys).toArray(),
() => database?.table("assets").bulkGet(assetKeys),
[database, assetKeys]
);
@ -169,13 +169,14 @@ export function AssetURLsProvider({ children }) {
if (!assets || assets.length === 0) {
return;
}
// Assets are about to be loaded so clear the keys to load
setAssetKeys([]);
setAssetURLs((prevURLs) => {
let newURLs = { ...prevURLs };
for (let asset of assets) {
if (newURLs[asset.id]?.url === null) {
if (asset && newURLs[asset.id]?.url === null) {
newURLs[asset.id] = {
...newURLs[asset.id],
url: URL.createObjectURL(