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

    Function updatePriceAlert

    • Applies changes to an alert, unless it was removed in the meantime.

      Parameters

      Returns Promise<boolean>

      Whether the alert still exists

      await updatePriceAlert(alert.id, { lastCheckedAt: Date.now(), failures: 0 });
      
      export async function updatePriceAlert(
      id: string,
      changes: Partial<Omit<PriceAlert, 'id'>>,
      ): Promise<boolean> {
      const key = priceAlertKey(id);
      const current: unknown = (await cstorage.local.get(key))[key];
      if (!isPriceAlert(current)) return false;
      await cstorage.local.set({ [key]: { ...current, ...changes } });
      return true;
      }