Repository navigation
conversation-activity-filter - Clean up state - #9999
Conversation
| $([ | ||
| // PR | ||
| '[class^="prc-PageLayout-PageLayoutWrapper"]', | ||
| // Issue | ||
| '[class*="IssueViewer-module__mainContainer"]', | ||
| ]).setAttribute('data-rgh-conversation-activity-filter', value); |
|
Tested a few things:
Broken:
|
|
@copilot the |
This comment was marked as low quality.
This comment was marked as low quality.
|
@copilot the minorFixesIssuePages defaults are overriding all choices, the state can't be changed. Ignore previous comments, only read this and address it |
This comment was marked as spam.
This comment was marked as spam.
32dac60 to
3d77f84
Compare
| 'https://github.com/refined-github/refined-github/issues/7000', | ||
| 'https://github.com/refined-github/refined-github/issues/7777', | ||
| 'https://github.com/refined-github/refined-github/issues/8000', | ||
| ]; |
There was a problem hiding this comment.
Dropped some closed issues
| // Find and hide stale reviews referenced by dismissed review events | ||
| for (const {hash: staleReviewId} of $$('.TimelineItem-body > a[href^="#pullrequestreview-"]', item)) { | ||
| closestElement(timelineItem, $(staleReviewId)) | ||
| $(is(timelineItem) + has(staleReviewId)) |
| target: anchor, | ||
| props: { | ||
| onStateChange: applyState, | ||
| }, |
There was a problem hiding this comment.
Now the state is controlled directly. The component used to read from the store, so why not set the store internally?
| async function init(signal: AbortSignal): Promise<void> { | ||
| const initialState = SessionPageSetting.get() | ||
| ?? (minorFixesIssuePages.some(url => location.href.startsWith(url)) | ||
| ? 'hideAllNoise' // Automatically hide resolved comments on "Minor codebase updates and fixes" issue pages | ||
| : 'showAll'); | ||
| activityFilterState.set(initialState); | ||
|
|
||
| const initialSetupOnce = onetime(() => { | ||
| if (initialState !== 'showAll') { | ||
| applyState(initialState); | ||
| } | ||
|
|
||
| registerHotkey('h', switchToNextFilter, {signal}); | ||
| }); |
There was a problem hiding this comment.
Very hard to follow.
Now:
initupdates the store
Period. The store itself will know its own defaults and where to read any stored state
| registerHotkey('h', switchToNextFilter, {signal}); | ||
|
|
||
| globalThis.addEventListener('hashchange', uncollapseTargetedComment, {signal}); | ||
| observe(timeline, syncWrapper, {signal}); |
There was a problem hiding this comment.
This call somewhat replaces initialSetupOnce as it subscribes the timeline's attribute directly to the store.
| function getInitialStateForUrl(pathname: string): State { | ||
| const initialState = sessionStorage.getItem(sessionKey(pathname)) | ||
| ?? defaults.get(pathname) | ||
| ?? 'showAll'; | ||
| return initialState as State; | ||
| } |
There was a problem hiding this comment.
Name and flow extremely clear now.
conversation-activity-filter: race condition #9992Test URLs
Screenshot
Tested, all good