Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants