Skip to content

Commit b673651

Browse files
linonetwoCopilot
andauthored
Fixes slow when import html on upgrade (TiddlyWiki#9689)
* Short-circuit the import option; only show it when you click a button * Add aira-label Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * perf(import): lazy evaluate import options panel, shortcircuit when no options, and flatten let widgets - Only parse $:/Import JSON when user expands the import options panel - Skip all import option logic if no $:/tags/ImportOptions tiddlers exist - Merge nested let widgets into single multi-variable let for better performance and readability - Add lingo for import options panel and no-match message This greatly improves import speed for large wikis, especially when no import options are present. * fix(import): use correct transclusion for aria-label on import options panel buttons\n\nBind aria-label using {{$:/language/Import/Listing/ImportOptions/Caption}} instead of macro literal, matching TiddlyWiki convention and ensuring accessibility tools read the correct label. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 49faefc commit b673651

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

core/language/en-GB/Import.multids

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Listing/Preview/TextRaw: Text (Raw)
1515
Listing/Preview/Fields: Fields
1616
Listing/Preview/Diff: Diff
1717
Listing/Preview/DiffFields: Diff (Fields)
18+
Listing/ImportOptions/Caption: Import options
19+
Listing/ImportOptions/NoMatch: No import options apply to these files.
1820
Listing/Rename/Tooltip: Rename tiddler before importing
1921
Listing/Rename/Prompt: Rename to:
2022
Listing/Rename/ConfirmRename: Rename tiddler

core/ui/ImportListing.tid

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,40 @@ title: $:/core/ui/ImportListing
4949
\end
5050

5151
\whitespace trim
52-
<$let importJson={{{ [{$:/Import}] }}}
53-
importTitles={{{ [<importJson>jsonindexes[tiddlers]] }}}
54-
importTypes={{{ [(importTitles)] :map[<importJson>jsonget[tiddlers],<currentTiddler>,[type]] }}}
55-
anyMatch={{{ [all[shadows+tiddlers]tag[$:/tags/ImportOptions]get[condition]] :map[(importTypes)subfilter<currentTiddler>] +[!is[blank]limit[1]] }}}>
56-
<%if [<anyMatch>!is[blank]] %>
57-
<div class="tc-import-option">
58-
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ImportOptions]]" variable="importOption">
59-
<$let condition={{{ [<importOption>get[condition]] }}}
60-
hasMatch={{{ [(importTypes)subfilter<condition>limit[1]] }}}>
61-
<%if [<hasMatch>!is[blank]] %>
62-
<$transclude tiddler=<<importOption>>/>
63-
<%endif%>
64-
</$let>
65-
</$list>
66-
</div>
67-
<%endif%>
68-
</$let>
52+
<%if [all[shadows+tiddlers]tag[$:/tags/ImportOptions]limit[1]] %>
53+
<$reveal type="nomatch" state="$:/state/import/options" text="yes" tag="div">
54+
<$button class="tc-btn-invisible tc-btn-dropdown" set="$:/state/import/options" setTo="yes" aria-label={{$:/language/Import/Listing/ImportOptions/Caption}} aria-expanded="false">
55+
<span class="tc-small-gap-right">{{$:/core/images/right-arrow}}</span><<lingo Listing/ImportOptions/Caption>>
56+
</$button>
57+
</$reveal>
58+
<$reveal type="match" state="$:/state/import/options" text="yes" tag="div">
59+
<$button class="tc-btn-invisible tc-btn-dropdown" set="$:/state/import/options" setTo="no" aria-label={{$:/language/Import/Listing/ImportOptions/Caption}} aria-expanded="true">
60+
<span class="tc-small-gap-right">{{$:/core/images/down-arrow}}</span><<lingo Listing/ImportOptions/Caption>>
61+
</$button>
62+
<$let importJson={{{ [{$:/Import}] }}}
63+
importTitles={{{ [<importJson>jsonindexes[tiddlers]] }}}
64+
importTypes={{{ [(importTitles)] :map[<importJson>jsonget[tiddlers],<currentTiddler>,[type]] }}}
65+
anyMatch={{{ [all[shadows+tiddlers]tag[$:/tags/ImportOptions]get[condition]] :map[(importTypes)subfilter<currentTiddler>] +[!is[blank]limit[1]] }}}>
66+
<%if [<anyMatch>!is[blank]] %>
67+
<div class="tc-import-option">
68+
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ImportOptions]]" variable="importOption">
69+
<$let condition={{{ [<importOption>get[condition]] }}}
70+
hasMatch={{{ [(importTypes)subfilter<condition>limit[1]] }}}>
71+
<%if [<hasMatch>!is[blank]] %>
72+
<$transclude tiddler=<<importOption>>/>
73+
<%endif%>
74+
</$let>
75+
</$list>
76+
</div>
77+
<%else%>
78+
<div class="tc-import-option">
79+
<<lingo Listing/ImportOptions/NoMatch>>
80+
</div>
81+
<%endif%>
82+
</$let>
83+
</$reveal>
84+
<%endif%>
85+
6986
<div class="tc-table-wrapper">
7087
<table class="tc-import-table">
7188
<tbody>

0 commit comments

Comments
 (0)