Opening a list moves the feed list's highlight instead of redrawing it (#490)
Profiled on production's lists at an iPhone 13's size with the CPU slowed 4x, opening four lists twice: selectFeed rebuilt every feed row (about 300 ms of the run) only to move .sel and aria-current, and dateOf made a new Intl.DateTimeFormat for every row through toLocaleDateString with options (about 155 ms). With markSelected and one shared formatter the run's CPU time fell from 2.3-2.5 s to 1.25-1.65 s; dateOf from 157 ms to 12 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RqkrVBuJRne2JAhFpaDV2U
This commit is contained in:
@@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
|
||||
- Opening a podcast or a list draws only the list: the feed list beside it is no longer rebuilt to move its highlight, and dates are written by one formatter rather than one a row, about 40% less work on a phone (#490).
|
||||
- A report of a reader that would not scroll no longer comes from a quick flick that did scroll, and says when the reader was last swiped across, not that it was just now (#488).
|
||||
- The headers of Currently Listening, Up Next, Playlists and Signals start where a podcast's does, rather than twice as far in and further down (#485).
|
||||
- On a phone, a pinned item's pin in the reader's floating actions is on its accent disc again, rather than nearly invisible on a light theme (#480).
|
||||
|
||||
@@ -204,7 +204,16 @@ function renderFeeds(){
|
||||
function selectFeed(id: string){
|
||||
S.feed=id; S.offset=0; S.sel=null; S.q=''; S.season=''; sortPicked=false; $<HTMLInputElement>('#epSearch').value='';
|
||||
try{ localStorage.setItem('ipx.feed',id); }catch{}
|
||||
renderFeeds(); renderFeed(); loadEntries();
|
||||
markSelected(); renderFeed(); loadEntries();
|
||||
}
|
||||
/// The highlight moved to the feed now open. Rebuilding every row for it, as selecting once did,
|
||||
/// was a third of a list's drawing time on a phone.
|
||||
function markSelected(){
|
||||
for(const el of $$<HTMLElement>('#feedlist [data-id]')){
|
||||
const on=el.dataset.id===S.feed;
|
||||
el.classList.toggle('sel',on);
|
||||
if(on) el.setAttribute('aria-current','page'); else el.removeAttribute('aria-current');
|
||||
}
|
||||
}
|
||||
|
||||
/// A failing feed's error, in plain words with something to do about it, once `failing` is
|
||||
|
||||
@@ -302,7 +302,9 @@ const ago = (t: number|null) => {
|
||||
if(d<2592000) return Math.round(d/86400)+'d ago';
|
||||
return new Date(t*1000).toLocaleDateString(undefined,{month:'short',day:'numeric',year:'numeric'});
|
||||
};
|
||||
const dateOf = (t: number|null) => t?new Date(t*1000).toLocaleDateString(undefined,{month:'short',day:'numeric',year:'numeric'}):'';
|
||||
// One formatter: toLocaleDateString with options makes a new one each call, every row of a list.
|
||||
const DATE_FMT = new Intl.DateTimeFormat(undefined,{month:'short',day:'numeric',year:'numeric'});
|
||||
const dateOf = (t: number|null) => t?DATE_FMT.format(t*1000):'';
|
||||
// A podcast episode is tens of MB, an article's image a few KB: whole MB made the small ones "0 MB".
|
||||
const mb = (n: number|null) => !n?'' : n<1048576?Math.max(1,Math.round(n/1024))+' KB'
|
||||
: n<1073741824?Math.round(n/1048576)+' MB' : (n/1073741824).toFixed(1)+' GB';
|
||||
|
||||
Reference in New Issue
Block a user