Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

[bug fix] Fix auto grouping doesn't work because isOn is undefined by default #61

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

jt-wang
Copy link
Contributor

@jt-wang jt-wang commented Dec 12, 2023

Theres' a bug that auto grouping doesn't work.

This is because in background.ts, it executes auto grouping only when Chrome local storage isOn is true.

const enable = await getStorage<boolean>("isOn");
  if (
    !enable ||
    !tab.id ||
    !tab.url ||
    window.type != "normal" ||
    !types.length ||
    (tab.status === "complete" && tab.url.startsWith("chrome://"))
  ) {
    return;
  }

However, isOn is by default undefined, because popup.tsx doesn't store isOn value to Chrome local storage, as the only place it sets is when user clicks on disableGrouping.

  const disableGrouping = () => {
    setIsOn((isOn) => {
      setStorage("isOn", !isOn);
      return !isOn;
    });
  };

Since isOn is undefined, backtround.ts won't execute auto grouping.

This PR fixes this.


#48 is aimed to avoid such bugs when these states should have been synced across browser storage and React states.

Copy link
Owner

@MichaelYuhe MichaelYuhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can use chrome.runtime.onInstalled.addListener to set enable in storage to true by default or just set default state to false.

@jt-wang
Copy link
Contributor Author

jt-wang commented Dec 12, 2023

@MichaelYuhe Great suggestion! updated.

@MichaelYuhe MichaelYuhe merged commit 8b5529d into MichaelYuhe:main Dec 12, 2023
1 check passed
@MichaelYuhe MichaelYuhe added the enhancement New feature or request label Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants