From fdefd907e364170395c04f15f49a95b13bee5510 Mon Sep 17 00:00:00 2001
From: Mitchell McCaffrey <mitchemmc@gmail.com>
Date: Fri, 23 Jul 2021 18:51:51 +1000
Subject: [PATCH] Update asset live query to use bulkGet to fix crash on
 private browsing Firefox

---
 src/contexts/AssetsContext.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/contexts/AssetsContext.js b/src/contexts/AssetsContext.js
index 4da276f..4ff0b03 100644
--- a/src/contexts/AssetsContext.js
+++ b/src/contexts/AssetsContext.js
@@ -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(