Update asset live query to use bulkGet to fix crash on private browsing Firefox
This commit is contained in:
parent
3aace97004
commit
fdefd907e3
@ -160,7 +160,7 @@ export function AssetURLsProvider({ children }) {
|
|||||||
|
|
||||||
// Get the new assets whenever the keys change
|
// Get the new assets whenever the keys change
|
||||||
const assets = useLiveQuery(
|
const assets = useLiveQuery(
|
||||||
() => database?.table("assets").where("id").anyOf(assetKeys).toArray(),
|
() => database?.table("assets").bulkGet(assetKeys),
|
||||||
[database, assetKeys]
|
[database, assetKeys]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -169,13 +169,14 @@ export function AssetURLsProvider({ children }) {
|
|||||||
if (!assets || assets.length === 0) {
|
if (!assets || assets.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assets are about to be loaded so clear the keys to load
|
// Assets are about to be loaded so clear the keys to load
|
||||||
setAssetKeys([]);
|
setAssetKeys([]);
|
||||||
|
|
||||||
setAssetURLs((prevURLs) => {
|
setAssetURLs((prevURLs) => {
|
||||||
let newURLs = { ...prevURLs };
|
let newURLs = { ...prevURLs };
|
||||||
for (let asset of assets) {
|
for (let asset of assets) {
|
||||||
if (newURLs[asset.id]?.url === null) {
|
if (asset && newURLs[asset.id]?.url === null) {
|
||||||
newURLs[asset.id] = {
|
newURLs[asset.id] = {
|
||||||
...newURLs[asset.id],
|
...newURLs[asset.id],
|
||||||
url: URL.createObjectURL(
|
url: URL.createObjectURL(
|
||||||
|
Loading…
Reference in New Issue
Block a user