Skip to content

Commit 1212e4d

Browse files
authored
ui: ipfs sharing fixes: (#162)
- show dialog if ipfs sharing fails, don't get stuck on spinner - also show dialog if unsharing fails, don't just remove sharing - bump awp-sw to 0.3.2
1 parent 35d919a commit 1212e4d

File tree

6 files changed

+189
-32
lines changed

6 files changed

+189
-32
lines changed

dist/embed/replay/sw.js

Lines changed: 130 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/embed/ui.js

Lines changed: 20 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"license": "AGPL-3.0-or-later",
1010
"dependencies": {
1111
"@fortawesome/fontawesome-free": "^5.13.0",
12-
"@webrecorder/awp-sw": "^0.3.1",
12+
"@webrecorder/awp-sw": "^0.3.2",
1313
"@webrecorder/wabac": "^2.16.3",
1414
"auto-js-ipfs": "^2.3.0",
1515
"browsertrix-behaviors": "^0.5.0",

src/ui/app.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ class ArchiveWebApp extends ReplayWebApp
8282

8383
ipfsOpts: { type: Object },
8484

85-
showSettings: {type: Boolean }
85+
showSettings: {type: Boolean },
86+
87+
showIpfsShareFailed: { type: Boolean }
8688
};
8789
}
8890

@@ -326,6 +328,7 @@ class ArchiveWebApp extends ReplayWebApp
326328
@show-start=${this.onShowStart}
327329
@show-import=${this.onShowImport}
328330
@colls-updated=${this.onCollsLoaded}
331+
@ipfs-share-failed=${(e) => this.showIpfsShareFailed = true}
329332
style="overflow: visible"
330333
>
331334
</wr-rec-coll-index>
@@ -339,6 +342,7 @@ class ArchiveWebApp extends ReplayWebApp
339342
${this.showImport ? this.renderImportModal() : ""}
340343
${this.showDownloadProgress && this.download ? this.renderDownloadModal() : ""}
341344
${this.showSettings ? this.renderSettingsModal() : ""}
345+
${this.showIpfsShareFailed ? this.renderIPFSShareFailedModal() : ""}
342346
${super.render()}`;
343347
}
344348

@@ -453,6 +457,16 @@ class ArchiveWebApp extends ReplayWebApp
453457
</wr-modal`;
454458
}
455459

460+
renderIPFSShareFailedModal() {
461+
return html`
462+
<wr-modal @modal-closed="${() => this.showIpfsShareFailed = false}" title="IPFS Connection Failed">
463+
<div>
464+
<p>Sorry, IPFS sharing / unsharing failed as IPFS could not be reached.</p>
465+
<p>(Check the IPFS settings and try again.)</p>
466+
</div>
467+
</wr-modal`;
468+
}
469+
456470
renderDownloadModal() {
457471
const renderDLStatus = () => {
458472
switch (this.download.state) {

src/ui/coll-info.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,18 @@ class WrRecCollInfo extends CollInfo
312312
this.shareWarn = false;
313313

314314
this.shareWait = true;
315-
const { ipfsURL } = await this.ipfsAdd();
316315

317-
this.ipfsURL = ipfsURL;
316+
try {
317+
const { ipfsURL } = await this.ipfsAdd();
318+
319+
this.ipfsURL = ipfsURL;
320+
321+
this.onCopyGatewayLink();
322+
} catch (e) {
323+
console.log("ipfs share failed");
324+
this.dispatchEvent(new CustomEvent("ipfs-share-failed", {bubbles: true, composed: true}));
325+
}
318326

319-
this.onCopyGatewayLink();
320327
this.shareWait = false;
321328
}
322329

@@ -326,6 +333,8 @@ class WrRecCollInfo extends CollInfo
326333

327334
if (removed) {
328335
this.ipfsURL = null;
336+
} else {
337+
this.dispatchEvent(new CustomEvent("ipfs-share-failed", {bubbles: true, composed: true}));
329338
}
330339
this.shareWait = false;
331340
}
@@ -375,6 +384,10 @@ class WrRecCollInfo extends CollInfo
375384
gzip: false,
376385
customSplits: true,
377386
})
387+
}).then((res) => {
388+
if (!res.ok) {
389+
pc.reject();
390+
}
378391
});
379392

380393
return p;
@@ -383,7 +396,9 @@ class WrRecCollInfo extends CollInfo
383396
async ipfsRemove() {
384397
const resp = await fetch(`${apiPrefix}/c/${this.coll.id}/ipfs`, {
385398
method: "DELETE",
386-
body: JSON.stringify({ipfsDaemonUrl: this.ipfsOpts.daemonUrl})
399+
body: JSON.stringify({
400+
ipfsDaemonUrl: this.ipfsOpts.daemonUrl
401+
})
387402
});
388403

389404
return await resp.json();

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -954,10 +954,10 @@
954954
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.6.0.tgz#2c275aa05c895eccebbfc34cfb223c6e8bd591a2"
955955
integrity sha512-ZkVeqEmRpBV2GHvjjUZqEai2PpUbuq8Bqd//vEYsp63J8WyexI8ppCqVS3Zs0QADf6aWuPdU+0XsPI647PVlQA==
956956

957-
"@webrecorder/awp-sw@^0.3.1":
958-
version "0.3.1"
959-
resolved "https://registry.yarnpkg.com/@webrecorder/awp-sw/-/awp-sw-0.3.1.tgz#8c9bcff465422af66e5ffb2ecea3a3886c544b6f"
960-
integrity sha512-YtgWDuwxWCkdSDH4TI9hene23KEIIKVsTjmQzmK2HiU+3kvvb/DUiHaL7t8wLKD3JZLKCoHZqoKzuMm7jm+udA==
957+
"@webrecorder/awp-sw@^0.3.2":
958+
version "0.3.2"
959+
resolved "https://registry.yarnpkg.com/@webrecorder/awp-sw/-/awp-sw-0.3.2.tgz#63da7b101f3d4e3c904abcb95eb7821d5f5fafb5"
960+
integrity sha512-e+7Oeu8tg7TbraHxr8dVdqreUtfKu9QpwCz/+KE8wM3uGrqc4wNIecUUxQcMI39V8n6i80LI/o7udji/PNQUFg==
961961
dependencies:
962962
"@ipld/car" "^5.1.1"
963963
"@ipld/unixfs" "^2.1.1"

0 commit comments

Comments
 (0)