-
Notifications
You must be signed in to change notification settings - Fork 0
share current page button #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -112,6 +112,13 @@ class ArgoViewer extends LitElement { | |||||||||||||||||||||||||||||||||||||
| color: #000; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| .status-divider { | ||||||||||||||||||||||||||||||||||||||
| width: 100%; | ||||||||||||||||||||||||||||||||||||||
| margin: 0.5rem 0; | ||||||||||||||||||||||||||||||||||||||
| border: none; | ||||||||||||||||||||||||||||||||||||||
| border-top: 1px solid #e0e0e0; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| img.favicon { | ||||||||||||||||||||||||||||||||||||||
| width: var(--md-icon-size) !important; | ||||||||||||||||||||||||||||||||||||||
| height: var(--md-icon-size) !important; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -226,6 +233,23 @@ class ArgoViewer extends LitElement { | |||||||||||||||||||||||||||||||||||||
| return ""; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private getCurrentPage() { | ||||||||||||||||||||||||||||||||||||||
| const sameUrls = this.archiveList | ||||||||||||||||||||||||||||||||||||||
| ?.getAllPages() | ||||||||||||||||||||||||||||||||||||||
| // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'ArgoViewer'. | ||||||||||||||||||||||||||||||||||||||
| .filter((p) => p.url === this.pageUrl); | ||||||||||||||||||||||||||||||||||||||
| if (!sameUrls || !sameUrls.length) { | ||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Sort by timestamp (newest first) | ||||||||||||||||||||||||||||||||||||||
| return sameUrls.sort((a, b) => { | ||||||||||||||||||||||||||||||||||||||
| const tsA = parseInt(a.ts, 10); | ||||||||||||||||||||||||||||||||||||||
| const tsB = parseInt(b.ts, 10); | ||||||||||||||||||||||||||||||||||||||
| return tsB - tsA; // Descending order (newest first) | ||||||||||||||||||||||||||||||||||||||
| })[0]; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private async onDownload() { | ||||||||||||||||||||||||||||||||||||||
| const selectedPages = this.archiveList?.getSelectedPages?.() || []; | ||||||||||||||||||||||||||||||||||||||
| if (!selectedPages.length) { | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -276,19 +300,33 @@ class ArgoViewer extends LitElement { | |||||||||||||||||||||||||||||||||||||
| console.log("WACZ file downloaded:", filename); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private async onShare() { | ||||||||||||||||||||||||||||||||||||||
| private async onShareSelected() { | ||||||||||||||||||||||||||||||||||||||
| const selectedPages = this.archiveList?.getSelectedPages?.() || []; | ||||||||||||||||||||||||||||||||||||||
| if (!selectedPages.length) { | ||||||||||||||||||||||||||||||||||||||
| alert("Please select some pages to share."); | ||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| console.log("Selected pages to share:", selectedPages); | ||||||||||||||||||||||||||||||||||||||
| await this.onShare(selectedPages); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private async onShareCurrent() { | ||||||||||||||||||||||||||||||||||||||
| const currentPage = this.getCurrentPage?.() || null; | ||||||||||||||||||||||||||||||||||||||
| if (!currentPage) { | ||||||||||||||||||||||||||||||||||||||
| alert("No current page to share."); | ||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| console.log("Current page to share:", currentPage); | ||||||||||||||||||||||||||||||||||||||
| await this.onShare([currentPage]); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+313
to
+321
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Remove the optional chaining operator (
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // @ts-expect-error - TS7006 - Parameter 'pages' implicitly has an 'any' type. | ||||||||||||||||||||||||||||||||||||||
| private async onShare(pages) { | ||||||||||||||||||||||||||||||||||||||
| const defaultCollId = (await getLocalOption("defaultCollId")) || ""; | ||||||||||||||||||||||||||||||||||||||
| const coll = await collLoader.loadColl(defaultCollId); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const pageTsList = selectedPages.map((p) => p.id); | ||||||||||||||||||||||||||||||||||||||
| // @ts-expect-error - TS7006 - Parameter 'p' implicitly has an 'any' type. | ||||||||||||||||||||||||||||||||||||||
| const pageTsList = pages.map((p) => p.id); | ||||||||||||||||||||||||||||||||||||||
| const format = "wacz"; | ||||||||||||||||||||||||||||||||||||||
| const filename = `archive-${Date.now()}.wacz`; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
@@ -654,13 +692,21 @@ class ArgoViewer extends LitElement { | |||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| ${ | ||||||||||||||||||||||||||||||||||||||
| // @ts-expect-error - TS2339 - Property 'status' does not exist on type 'ArgoViewer'. | TS2339 - Property 'status' does not exist on type 'ArgoViewer'. | ||||||||||||||||||||||||||||||||||||||
| !this.status?.numPending | ||||||||||||||||||||||||||||||||||||||
| !this.status?.numPending && this.pageUrl | ||||||||||||||||||||||||||||||||||||||
| ? html`<div class="status-container"> | ||||||||||||||||||||||||||||||||||||||
| <md-icon filled style="color: var(--md-sys-color-primary);" | ||||||||||||||||||||||||||||||||||||||
| >check_circle</md-icon | ||||||||||||||||||||||||||||||||||||||
| <md-icon filled style="color: var(--md-sys-color-primary);" | ||||||||||||||||||||||||||||||||||||||
| >check_circle</md-icon | ||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||
| <span class="status-content">All resources archived</span> | ||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||
| <hr class="status-divider" /> | ||||||||||||||||||||||||||||||||||||||
| <md-filled-button | ||||||||||||||||||||||||||||||||||||||
| style="color: white; border-radius: 9999px; align-self: flex-end;" | ||||||||||||||||||||||||||||||||||||||
| @click=${this.onShareCurrent} | ||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||
| <span class="status-content">All resources archived</span> | ||||||||||||||||||||||||||||||||||||||
| </div>` | ||||||||||||||||||||||||||||||||||||||
| <md-icon slot="icon" style="color:white">share</md-icon> | ||||||||||||||||||||||||||||||||||||||
| Share Current Page | ||||||||||||||||||||||||||||||||||||||
| </md-filled-button> ` | ||||||||||||||||||||||||||||||||||||||
| : "" | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| </div>`; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -828,7 +874,10 @@ class ArgoViewer extends LitElement { | |||||||||||||||||||||||||||||||||||||
| <md-icon style="color: gray;">download</md-icon> | ||||||||||||||||||||||||||||||||||||||
| </md-icon-button> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| <md-icon-button aria-label="Share" @click=${this.onShare}> | ||||||||||||||||||||||||||||||||||||||
| <md-icon-button | ||||||||||||||||||||||||||||||||||||||
| aria-label="Share" | ||||||||||||||||||||||||||||||||||||||
| @click=${this.onShareSelected} | ||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||
| <md-icon style="color: gray;">share</md-icon> | ||||||||||||||||||||||||||||||||||||||
| </md-icon-button> | ||||||||||||||||||||||||||||||||||||||
| ` | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add null check for
this.archiveListbefore accessinggetAllPages()to prevent potential runtime errors whenarchiveListis null or undefined. [possible issue, importance: 8]