Add thumbnail sending to assets for map grid

This commit is contained in:
Mitchell McCaffrey
2021-04-29 15:44:57 +10:00
parent 0ccee84cbf
commit 71edf5c5c5
6 changed files with 38 additions and 48 deletions

View File

@@ -5,8 +5,7 @@ import React, {
useCallback,
useRef,
} from "react";
import * as Comlink from "comlink";
import { decode, encode } from "@msgpack/msgpack";
import { decode } from "@msgpack/msgpack";
import { useAuth } from "./AuthContext";
import { useDatabase } from "./DatabaseContext";
@@ -215,16 +214,7 @@ export function MapDataProvider({ children }) {
*/
const putMap = useCallback(
async (map) => {
// Attempt to use worker to put map to avoid UI lockup
const packedMap = encode(map);
const success = await worker.putData(
Comlink.transfer(packedMap, [packedMap.buffer]),
"maps",
false
);
if (!success) {
await database.table("maps").put(map);
}
await database.table("maps").put(map);
if (map.owner !== userId) {
await updateCache();
}