Using pouchdb instead of redux to store tracks.

This commit is contained in:
vdv committed 2022-09-24 17:08:53 +02:00
1 parent d82d972ff2
commit eae6296c2a
10 files changed
+341 -88

No files matched your search

+1
View File
@@ -0,0 +1 @@
declare module 'react-pouchdb';
+22
View File
@@ -0,0 +1,22 @@
import {
Sha256,
Sha512,
string_to_bytes,
bytes_to_base64,
} from '@openpgp/asmcrypto.js';
export const pushTrack = (db: any, payload: any) => {
const sha = new Sha256();
const result = sha
.process(string_to_bytes(JSON.stringify(payload.track)))
.finish().result;
var _id;
if (result === null) {
console.log(`Can't hash`);
_id = crypto.randomUUID();
} else {
_id = bytes_to_base64(result);
console.log(`Digest: ${_id}`);
}
db.put({ _id, type: 'Track', ...payload });
};