Skip to content

Commit cafe788

Browse files
committed
Fix potential profile change handler error storycraft#273
1 parent 852a581 commit cafe788

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/packet/chat/sync-link-pf.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export interface SyncLinkPfRes {
1212
/**
1313
* Channel id
1414
*/
15-
c: Long;
15+
c?: Long;
1616

1717
/**
1818
* Link id
1919
*/
20-
li: Long;
20+
li?: Long;
2121

2222
/**
2323
* Updated open link user

src/talk/openlink/talk-open-channel-handler.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,17 @@ export class TalkOpenChannelHandler<T extends OpenChannel> implements Managed<Ta
9090
pfData: DefaultRes & SyncLinkPfRes,
9191
parentCtx: EventContext<TalkOpenChannelEvents<T>>
9292
) {
93-
if (!this._channel.channelId.eq(pfData.c) && !this._channel.linkId.eq(pfData.li)) return;
93+
if (
94+
pfData.c && !this._channel.channelId.eq(pfData.c) ||
95+
pfData.li && !this._channel.linkId.eq(pfData.li)
96+
) return;
9497

95-
const updated = structToOpenLinkChannelUserInfo(pfData.olu);
96-
const last = this._store.getUserInfo(updated);
98+
const last = this._store.getUserInfo(pfData.olu);
9799
if (!last) return;
98100

99-
this._store.updateUserInfo(updated, updated);
101+
const updated = structToOpenLinkChannelUserInfo(pfData.olu);
102+
103+
this._store.updateUserInfo(last, updated);
100104

101105
this._callEvent(
102106
parentCtx,

0 commit comments

Comments
 (0)