Skip to content

Commit

Permalink
fix(connect): emit changed event with state change in keepSession
Browse files Browse the repository at this point in the history
  • Loading branch information
martykan committed Nov 6, 2024
1 parent d2f876e commit 4cbaf36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/connect/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,15 @@ const onCallDevice = async (
}
// Work done

if (
method.keepSession &&
method.deviceState &&
method.deviceState.sessionId !== device.getState()?.sessionId
) {
// if session was changed from the one that was sent, send a device changed event
sendCoreMessage(createDeviceMessage(DEVICE.CHANGED, device.toMessageObject()));
}

// TODO: This requires a massive refactoring https://github.com/trezor/trezor-suite/issues/5323
// @ts-expect-error TODO: messageResponse should be assigned from the response of "inner" function
const response = messageResponse;
Expand Down
2 changes: 1 addition & 1 deletion suite-common/wallet-core/src/device/deviceReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const mergeDeviceState = (
// state was previously not defined, we can set it
device.state === undefined ||
// update sessionId for the same staticSessionId
(upcomingState?.sessionId &&
(upcomingState &&
device.state?.staticSessionId === upcomingState.staticSessionId &&
device.state?.sessionId !== upcomingState.sessionId)
) {
Expand Down

0 comments on commit 4cbaf36

Please sign in to comment.