From 90a7f9b846bfe41bcb79adbe3af970e4825849d5 Mon Sep 17 00:00:00 2001 From: Filipp Sher Date: Tue, 27 Aug 2024 12:24:34 +0300 Subject: [PATCH] chore: rename dynamic data to live data --- src/api/Action/Action.ts | 23 ++++++++++------------- src/api/actions-spec.ts | 2 +- src/ui/ActionContainer.tsx | 12 ++++++------ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/api/Action/Action.ts b/src/api/Action/Action.ts index 1a432d69..5c2d974c 100644 --- a/src/api/Action/Action.ts +++ b/src/api/Action/Action.ts @@ -26,7 +26,7 @@ import { const MULTI_VALUE_TYPES: ActionParameterType[] = ['checkbox']; -const EXPERIMENTAL_DYNAMIC_DATA_DEFAULT_DELAY_MS = 1000; +const EXPERIMENTAL_LIVE_DATA_DEFAULT_DELAY_MS = 1000; interface ActionMetadata { blockchainIds?: string[]; @@ -42,13 +42,13 @@ type ActionChainMetadata = isChained: false; }; -interface DynamicData { +interface LiveData { enabled: boolean; delayMs?: number; } interface ExperimentalFeatures { - dynamicData?: DynamicData; + liveData?: LiveData; } export class Action { @@ -80,21 +80,18 @@ export class Action { } // this API MAY change in the future - public get dynamicData_experimental(): Required | null { - const dynamicData = this._experimental?.dynamicData; + public get liveData_experimental(): Required | null { + const liveData = this._experimental?.liveData; - if (!dynamicData) { + if (!liveData) { return null; } return { - enabled: dynamicData.enabled, - delayMs: dynamicData.delayMs - ? Math.max( - dynamicData.delayMs, - EXPERIMENTAL_DYNAMIC_DATA_DEFAULT_DELAY_MS, - ) - : EXPERIMENTAL_DYNAMIC_DATA_DEFAULT_DELAY_MS, + enabled: liveData.enabled, + delayMs: liveData.delayMs + ? Math.max(liveData.delayMs, EXPERIMENTAL_LIVE_DATA_DEFAULT_DELAY_MS) + : EXPERIMENTAL_LIVE_DATA_DEFAULT_DELAY_MS, }; } diff --git a/src/api/actions-spec.ts b/src/api/actions-spec.ts index 5680c3a8..83d5aef1 100644 --- a/src/api/actions-spec.ts +++ b/src/api/actions-spec.ts @@ -260,7 +260,7 @@ export interface ActionError { // Dialect's extensions to the Actions API export interface DialectExperimentalFeatures { dialectExperimental?: { - dynamicData?: { + liveData?: { enabled: boolean; delayMs?: number; // default 1000 (1s) }; diff --git a/src/ui/ActionContainer.tsx b/src/ui/ActionContainer.tsx index 6ed8fc7d..79d05d12 100644 --- a/src/ui/ActionContainer.tsx +++ b/src/ui/ActionContainer.tsx @@ -301,10 +301,10 @@ export const ActionContainer = ({ }, [action, websiteUrl]); useEffect(() => { - const dynamicDataConfig = action.dynamicData_experimental; + const liveDataConfig = action.liveData_experimental; if ( - !dynamicDataConfig || - !dynamicDataConfig.enabled || + !liveDataConfig || + !liveDataConfig.enabled || executionState.status !== 'idle' || action.isChained ) { @@ -322,15 +322,15 @@ export const ActionContainer = ({ } } catch (e) { console.error( - `[@dialectlabs/blinks] Failed to fetch dynamic data for action ${action.url}`, + `[@dialectlabs/blinks] Failed to fetch live data for action ${action.url}`, ); // if fetch failed, we retry after the same delay - timeout = setTimeout(fetcher, dynamicDataConfig.delayMs); + timeout = setTimeout(fetcher, liveDataConfig.delayMs); } }; // since either way we're rebuilding the whole action, we'll update and restart this effect - timeout = setTimeout(fetcher, dynamicDataConfig.delayMs); + timeout = setTimeout(fetcher, liveDataConfig.delayMs); return () => { clearTimeout(timeout);