Skip to content

Commit

Permalink
fix: don't account for context.status
Browse files Browse the repository at this point in the history
  • Loading branch information
dalechyn committed Jul 26, 2024
1 parent 36cdb8f commit 533a083
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
11 changes: 5 additions & 6 deletions src/utils/getFrameContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ export async function getFrameContext<
const url = parsePath(reset ? `${origin}${initialPath}` : context.url)

let previousState = await (async () => {
if (context.status === 'initial') {
if (typeof parameters.initialState === 'function')
return await (parameters.initialState as any)(contextHono)
return parameters.initialState
}
return context?.previousState
if (context.previousState) return context.previousState

if (typeof parameters.initialState === 'function')
return await (parameters.initialState as any)(contextHono)
return parameters.initialState
})()

function deriveState(
Expand Down
9 changes: 5 additions & 4 deletions src/utils/getImageContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ export async function getImageContext<
>(
parameters: GetImageContextParameters<env, path, input, _state>,
): GetImageContextReturnType<env, path, input, _state> {
const { context, contextHono, initialState } = parameters
const { context, contextHono } = parameters
const { env, previousState, req } = context || {}

return {
context: {
env,
previousState: await (async () => {
if (previousState) return previousState
if (typeof initialState === 'function')
return await (initialState as any)(contextHono)
return initialState

if (typeof parameters.initialState === 'function')
return await (parameters.initialState as any)(contextHono)
return parameters.initialState
})(),
req,
res: (data) => ({ data, format: 'image', status: 'success' }),
Expand Down
11 changes: 5 additions & 6 deletions src/utils/getSignatureContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ export async function getSignatureContext<
} = context || {}

const previousState = await (async () => {
if (context?.previousState === undefined) {
if (typeof parameters.initialState === 'function')
return await (parameters.initialState as any)(contextHono)
return parameters.initialState
}
return context?.previousState
if (context.previousState) return context.previousState

if (typeof parameters.initialState === 'function')
return await (parameters.initialState as any)(contextHono)
return parameters.initialState
})()

const { buttonValue, inputText } = getIntentState({
Expand Down
11 changes: 5 additions & 6 deletions src/utils/getTransactionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ export async function getTransactionContext<
} = context || {}

const previousState = await (async () => {
if (context?.previousState === undefined) {
if (typeof parameters.initialState === 'function')
return await (parameters.initialState as any)(contextHono)
return parameters.initialState
}
return context.previousState
if (context.previousState) return context.previousState

if (typeof parameters.initialState === 'function')
return await (parameters.initialState as any)(contextHono)
return parameters.initialState
})()

const { buttonValue, inputText } = getIntentState({
Expand Down

0 comments on commit 533a083

Please sign in to comment.