Fixed bug with large map sizes

This commit is contained in:
Mitchell McCaffrey 2020-06-07 11:19:32 +10:00
parent f4a6252360
commit 73aec132e7
2 changed files with 6 additions and 2 deletions

View File

@ -55,7 +55,9 @@ export function MapDataProvider({ children }) {
} }
async function loadMaps() { async function loadMaps() {
let storedMaps = await database.table("maps").toArray(); let storedMaps = [];
// Use a cursor instead of toArray to prevent IPC max size error
database.table("maps").each((map) => storedMaps.push(map));
const sortedMaps = storedMaps.sort((a, b) => b.created - a.created); const sortedMaps = storedMaps.sort((a, b) => b.created - a.created);
const defaultMapsWithIds = await getDefaultMaps(); const defaultMapsWithIds = await getDefaultMaps();
const allMaps = [...sortedMaps, ...defaultMapsWithIds]; const allMaps = [...sortedMaps, ...defaultMapsWithIds];

View File

@ -30,7 +30,9 @@ export function TokenDataProvider({ children }) {
} }
async function loadTokens() { async function loadTokens() {
let storedTokens = await database.table("tokens").toArray(); let storedTokens = [];
// Use a cursor instead of toArray to prevent IPC max size error
database.table("tokens").each((token) => storedTokens.push(token));
const sortedTokens = storedTokens.sort((a, b) => b.created - a.created); const sortedTokens = storedTokens.sort((a, b) => b.created - a.created);
const defaultTokensWithIds = getDefaultTokes(); const defaultTokensWithIds = getDefaultTokes();
const allTokens = [...sortedTokens, ...defaultTokensWithIds]; const allTokens = [...sortedTokens, ...defaultTokensWithIds];