Update hash on publish

This commit is contained in:
Julien Eluard 2018-10-23 19:24:34 +02:00
parent 2c1913b9ac
commit 31ec74c26a
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6

View File

@ -23,9 +23,10 @@
ipfs.once("ready", async () => {
let params = (new URL(document.location)).searchParams;
let hash = params.get("hash");
const content = await load(hash || "QmYoa8CBcYmzm6Kd1NbPNLYQtbwMpwR7YBiywaAyST5gtH");
let hash = params.get("hash") || "QmYoa8CBcYmzm6Kd1NbPNLYQtbwMpwR7YBiywaAyST5gtH";
const content = await load(hash);
codeMirror.setValue(content);
history.replaceState({hash: hash}, null, document.location.href.split('?')[0] + "?hash=" + hash);
});
function extensionLink(hash) {
@ -39,7 +40,9 @@
async function publish() {
const content = codeMirror.getValue();
const filesAdded = await uploadIPFS(ipfs, content);
displayQR(extensionLink(filesAdded[0].hash));
const hash = filesAdded[0].hash;
history.pushState({hash: hash}, null, document.location.href.split('?')[0] + "?hash=" + hash);
displayQR(extensionLink(hash));
}
function clearErrors() {