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

    Function recordProductPrices

    • Record the current USD price of each product (and its variants) into the price-history store. Fire-and-forget: the caller wraps this in void from the search flow, but the returned promise is also tracked internally so flushPendingPriceHistory can wait for it — the MV3 popup can be closed (destroying its JS context) the instant results are shown, before a sequential multi-series write finishes.

      Parameters

      • products: Product[]

        The products to record; each may carry variants.

      • Optionalsettings: PriceHistorySettings

        The user's priceTracking settings (enabled, maxDataPoints). Tracking is on unless explicitly disabled.

      Returns Promise<void>

      Resolves once all series have been processed.

      void recordProductPrices(finalResults, appContext.userSettings);
      
      export function recordProductPrices(
      products: Product[],
      settings?: PriceHistorySettings,
      ): Promise<void> {
      const task = doRecordProductPrices(products, settings);
      pendingWrites.add(task);
      void task.finally(() => pendingWrites.delete(task));
      return task;
      }