diff options
author | 2022-10-12 22:01:19 +0700 | |
---|---|---|
committer | 2022-10-12 22:01:19 +0700 | |
commit | 5e50f671fcfbf5a81748e5847a24363c64991fa6 (patch) | |
tree | f3e22889b43f16925bcfea8c2a4ccb8cf73c87f4 /source/features/toggle-files-button.tsx | |
parent | 5b07eab9f9e489d3cfa75d6ad1c06198199d6096 (diff) | |
download | refined-github-5e50f671fcfbf5a81748e5847a24363c64991fa6.tar.gz refined-github-5e50f671fcfbf5a81748e5847a24363c64991fa6.tar.zst refined-github-5e50f671fcfbf5a81748e5847a24363c64991fa6.zip |
Preserve `toggle-files-button` after navigation (#6079)
Diffstat (limited to 'source/features/toggle-files-button.tsx')
-rw-r--r-- | source/features/toggle-files-button.tsx | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/source/features/toggle-files-button.tsx b/source/features/toggle-files-button.tsx index 8ca2618b..20990092 100644 --- a/source/features/toggle-files-button.tsx +++ b/source/features/toggle-files-button.tsx @@ -67,22 +67,15 @@ async function updateView(anchor: HTMLHeadingElement): Promise<void> { const filesBox = anchor.parentElement!; addButton(filesBox); if (await cache.get<boolean>(cacheKey)) { - addFilesHiddenNotice(filesBox); - } -} - -async function loadPreviousState(): Promise<void> { - const wasHidden = await cache.get<boolean>(cacheKey); - if (wasHidden) { toggle(true); + addFilesHiddenNotice(filesBox); } } async function init(signal: AbortSignal): Promise<void> { // TODO: Use `.Box:has(> #files)` instead - observe('.repository-content h2#files', updateView, {signal}); + observe('.Box h2#files', updateView, {signal}); delegate(document, `.${toggleButtonClass}, .${noticeClass}`, 'click', toggleHandler, {signal}); - await loadPreviousState(); } void features.add(import.meta.url, { |