Skip to content

Commit

Permalink
chore: rename dynamic data to live data
Browse files Browse the repository at this point in the history
  • Loading branch information
fsher committed Aug 27, 2024
1 parent 643e4be commit 90a7f9b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
23 changes: 10 additions & 13 deletions src/api/Action/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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 {
Expand Down Expand Up @@ -80,21 +80,18 @@ export class Action {
}

// this API MAY change in the future
public get dynamicData_experimental(): Required<DynamicData> | null {
const dynamicData = this._experimental?.dynamicData;
public get liveData_experimental(): Required<LiveData> | 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,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/actions-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down
12 changes: 6 additions & 6 deletions src/ui/ActionContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -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);
Expand Down

0 comments on commit 90a7f9b

Please sign in to comment.