ChemPal Documentation - v1.18.0
    Preparing search index...

    Function showDropBadge

    • Shows the number of products with an unseen drop on the badge.

      Parameters

      • count: number

        Number of products

      • shouldFlash: boolean

        Whether to flash the badge for a moment first

      Returns Promise<void>

      Resolves once the badge is set; flashing continues after that

      await showDropBadge(2, true);
      
      export async function showDropBadge(count: number, shouldFlash: boolean): Promise<void> {
      const { color, flashColor, flashIntervalMs, flashSeconds } = priceAlertsConfig.badge;
      const text = dropBadgeText(count);
      // Setting the text blanks it first, which would be a visible blink.
      if ((await chrome.action.getBadgeText({})) !== text) await BadgeAnimator.setText(text);
      await BadgeAnimator.setColor(undefined, color);
      if (shouldFlash) {
      void BadgeAnimator.flash([color, flashColor], flashIntervalMs, flashSeconds * 1000);
      }
      }