Using pouchdb instead of redux to store tracks.
This commit is contained in:
1 parent
d82d972ff2
commit
eae6296c2a
10 files changed
+341
-88
No files matched your search
Vendored
+1
@@ -0,0 +1 @@
|
||||
declare module 'react-pouchdb';
|
||||
@@ -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 });
|
||||
};
|
||||
Reference in new issue
Block a user