Skip to content

Commit 60b8269

Browse files
remy90claude
andcommitted
fix: resolve group sender names via lid mapping
Group participants come through as LIDs while saved contacts are keyed by phone number, so getContactName never matched them. Look the LID up in the LID to phone number mapping before giving up. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 744b491 commit 60b8269

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎src/state/AppState.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,27 @@ describe("AppState", () => {
250250
})
251251
})
252252

253+
describe("getContactName", () => {
254+
beforeEach(() => {
255+
appState.setContactsCache(new Map([["[email protected]", "Alice"]]))
256+
})
257+
258+
it("should return the saved name for a phone number ID", () => {
259+
expect(appState.getContactName("[email protected]")).toBe("Alice")
260+
})
261+
262+
it("should resolve a LID to the saved name via the LID mapping", () => {
263+
appState.addLidMappings([{ lid: "123456789012345@lid", pn: "[email protected]" }])
264+
expect(appState.getContactName("123456789012345@lid")).toBe("Alice")
265+
})
266+
267+
it("should return undefined for a LID with no saved contact", () => {
268+
appState.addLidMappings([{ lid: "999999999999999@lid", pn: "[email protected]" }])
269+
expect(appState.getContactName("999999999999999@lid")).toBeUndefined()
270+
expect(appState.getContactName("888888888888888@lid")).toBeUndefined()
271+
})
272+
})
273+
253274
describe("setQrCode", () => {
254275
it("should update qrCode in state", () => {
255276
appState.setQrCode("2@testqrcodevalue")

‎src/state/AppState.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,10 @@ class StateManager {
473473
}
474474

475475
getContactName(contactId: string): string | undefined {
476-
return this.contactSlice.getContactName(contactId)
476+
const name = this.contactSlice.getContactName(contactId)
477+
if (name) return name
478+
const phoneId = this.chatSlice.getPhoneFromLid(contactId)
479+
return phoneId ? this.contactSlice.getContactName(phoneId) : undefined
477480
}
478481

479482
setMyProfile(myProfile: MyProfile | null): void {

0 commit comments

Comments
 (0)