message: Persist `toggle-files-button` state
diff: import './toggle-files-button.css';
  +import cache from 'webext-storage-cache';
  import React from 'dom-chef';
  import select from 'select-dom';
  import delegate from 'delegate-it';
  +import elementReady from 'element-ready';
  import * as pageDetect from 'github-url-detection';
  import FoldIcon from 'octicon/fold.svg';
  @@ -10,6 +12,8 @@ import UnfoldIcon from 'octicon/unfold.svg';
  import features from '.';
  import observeElement from '../helpers/simplified-element-observer';
  +const cacheKey = 'files-hidden';
  +
  function addButton(): void {
  // `div` excludes `include-fragment`, which means the list is still loading. #2160
  const filesHeader = select([
  @@ -25,7 +29,6 @@ function addButton(): void {
  type="button"
  className="btn-octicon rgh-toggle-files"
  aria-label="Toggle files section"
  - aria-expanded="true"
  >
  <FoldIcon/>
  <UnfoldIcon/>
  @@ -33,12 +36,23 @@ function addButton(): void {
  );
  }
  -function init(): void {
  - const repoContent = select('.repository-content')!;
  +async function toggleHandler(): Promise<void> {
  + const isHidden = select('.repository-content')!.classList.toggle('rgh-files-hidden');
  + if (isHidden) {
  + await cache.set(cacheKey, true);
  + } else {
  + await cache.delete(cacheKey);
  + }
  +}
  +
  +async function init(): Promise<void> {
  + const repoContent = (await elementReady('.repository-content'))!;
  observeElement(repoContent, addButton);
  - delegate(document, '.rgh-toggle-files', 'click', ({delegateTarget}) => {
  - delegateTarget.setAttribute('aria-expanded', String(!repoContent.classList.toggle('rgh-files-hidden')));
  - });
  + delegate(document, '.rgh-toggle-files', 'click', toggleHandler);
  +
  + if (await cache.get<boolean>(cacheKey)) {
  + repoContent.classList.add('rgh-files-hidden');
  + }
  }
  void features.add({
  @@ -49,5 +63,7 @@ void features.add({
  include: [
  pageDetect.isRepoTree
  ],
  + awaitDomReady: false,
  + repeatOnBackButton: true,
  init
  });
  