Skip to content

Commit 4cbaf36

Browse files
committed
fix(connect): emit changed event with state change in keepSession
1 parent d2f876e commit 4cbaf36

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/connect/src/core/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,15 @@ const onCallDevice = async (
696696
}
697697
// Work done
698698

699+
if (
700+
method.keepSession &&
701+
method.deviceState &&
702+
method.deviceState.sessionId !== device.getState()?.sessionId
703+
) {
704+
// if session was changed from the one that was sent, send a device changed event
705+
sendCoreMessage(createDeviceMessage(DEVICE.CHANGED, device.toMessageObject()));
706+
}
707+
699708
// TODO: This requires a massive refactoring https://github.com/trezor/trezor-suite/issues/5323
700709
// @ts-expect-error TODO: messageResponse should be assigned from the response of "inner" function
701710
const response = messageResponse;

suite-common/wallet-core/src/device/deviceReducer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const mergeDeviceState = (
6767
// state was previously not defined, we can set it
6868
device.state === undefined ||
6969
// update sessionId for the same staticSessionId
70-
(upcomingState?.sessionId &&
70+
(upcomingState &&
7171
device.state?.staticSessionId === upcomingState.staticSessionId &&
7272
device.state?.sessionId !== upcomingState.sessionId)
7373
) {

0 commit comments

Comments
 (0)