-
Notifications
You must be signed in to change notification settings - Fork 18
Toolbox install: report crawl progress and explain an empty install list #44
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
Open
mojie126
wants to merge
4
commits into
TypesettingTools:main
Choose a base branch
from
mojie126:toolbox-install-progress-feedback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
87dabbe
Toolbox install: report progress and explain an empty install list
mojie126 0b2d72a
Address review: check the built dialog lists, not the namespace tables
mojie126 ff02a11
FeedInventory: optional onProgress callback reporting crawl progress
mojie126 8cbd650
Toolbox install: moving progress bar and cancellation during the crawl
mojie126 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,10 @@ logger.usePrefixWindow = false | |
| msgs = { | ||
| install: { | ||
| scanning: "Scanning %d available feeds...", | ||
| scanningTask: "Scanning available feeds..." | ||
| loadingTask: "Loading feed data..." | ||
| empty: "All available scripts are already installed." | ||
| emptyUnfetched: "No scripts are available to install (%d of %d known feeds could not be fetched)." | ||
| createScriptUpdateRecordFailed: "Failed to create an update record for %s '%s' from feed %s: %s" | ||
| } | ||
| uninstall: { | ||
|
|
@@ -218,11 +222,16 @@ promptUntrustedFeed = (url, ft) -> | |
|
|
||
| -- Crawls the feed inventory with the untrusted-feed prompter active (so the `prompt` policy asks), scoped | ||
| -- so the prompter never leaks into background fetches. Shared by install discovery and Manage Feeds. | ||
| crawlWithPrompt = (inventory) -> | ||
| -- The pcall keeps a cancellation raised from onProgress from skipping the prompter reset; | ||
| -- returns nil when the crawl was cancelled and re-raises anything else. | ||
| crawlWithPrompt = (inventory, onProgress) -> | ||
| feedTrust = DepCtrl.updater.feedTrust | ||
| feedTrust\setPrompter promptUntrustedFeed | ||
| entries = inventory\crawl! | ||
| ok, entries = pcall inventory.crawl, inventory, onProgress | ||
| feedTrust\setPrompter nil | ||
| if not ok and entries != "cancelled" | ||
| error entries, 0 | ||
| return nil unless ok | ||
| entries | ||
|
|
||
| -- Macros | ||
|
|
@@ -261,8 +270,14 @@ install = -> | |
| -- FeedInventory crawls the known feeds, which are trust-gated and bounded. The shared feed loader then | ||
| -- serves each reachable feed's data from the cache the crawl just populated. | ||
| macros, modules = {}, {} | ||
| entries = crawlWithPrompt buildFeedInventory! | ||
|
|
||
| aegisub.progress.task msgs.install.scanningTask | ||
| entries = crawlWithPrompt buildFeedInventory!, (fetched, known) -> | ||
| aegisub.progress.set math.floor fetched * 100 / known | ||
| error "cancelled", 0 if aegisub.progress.is_cancelled! | ||
| aegisub.progress.set 100 | ||
| return unless entries | ||
|
|
||
| aegisub.progress.task msgs.install.loadingTask | ||
|
Contributor
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. does this one show for any appreciable time for you? It doesn't hurt to have this, but if loading the feeds after fetching is near-instant for you and you haven't disabled the feed cache then it's worth investigating why. |
||
| logger\log msgs.install.scanning, #entries | ||
| for entry in *entries | ||
| continue unless entry.fetched | ||
|
|
@@ -273,6 +288,13 @@ install = -> | |
| moduleList, moduleMap = buildDlgList modules | ||
| macroList, macroMap = buildDlgList macros | ||
|
|
||
| if #moduleList == 0 and #macroList == 0 | ||
| unfetched = #[entry for entry in *entries when not entry.fetched] | ||
| message = unfetched > 0 and msgs.install.emptyUnfetched\format(unfetched, #entries) or msgs.install.empty | ||
| aegisub.dialog.display {{class: "label", x: 0, y: 0, width: 1, height: 1, label: message}}, | ||
| {buttons.close}, {ok: buttons.close, cancel: buttons.close} | ||
| return | ||
|
|
||
| btn, res = aegisub.dialog.display getScriptListDlg macroList, moduleList | ||
| return unless btn | ||
|
|
||
|
|
||
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
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.
it would be even better if this one actually displayed a moving progress bar but that would involve adding a progress callback to
FeedInventory.crawl(), so if you'd rather keep it simple, leave it is and I'll add it to my TODO list as a low priority item.