summaryrefslogtreecommitdiff
path: root/source/features/toggle-files-button.tsx
diff options
context:
space:
mode:
authorGravatar Federico Brigante <me@fregante.com> 2022-10-12 22:01:19 +0700
committerGravatar GitHub <noreply@github.com> 2022-10-12 22:01:19 +0700
commit5e50f671fcfbf5a81748e5847a24363c64991fa6 (patch)
treef3e22889b43f16925bcfea8c2a4ccb8cf73c87f4 /source/features/toggle-files-button.tsx
parent5b07eab9f9e489d3cfa75d6ad1c06198199d6096 (diff)
downloadrefined-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.tsx11
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, {