Skip to content

Fix viewer showing wrong user for single-DM exports#655

Merged
rusq merged 2 commits intorusq:masterfrom
shehrozsheikh:fix/viewer-dm-display-name
Mar 29, 2026
Merged

Fix viewer showing wrong user for single-DM exports#655
rusq merged 2 commits intorusq:masterfrom
shehrozsheikh:fix/viewer-dm-display-name

Conversation

@shehrozsheikh
Copy link
Copy Markdown
Contributor

Fixes #654.

mostFrequentMember relies on Go map iteration order to find the current user. With a single DM, both members have frequency 1 and the result is non-deterministic. This breaks the viewer sidebar display about half the time.

When a tie is detected, this falls back to the last member of the first DM entry, which matches slackdump's export ordering ([other_user, current_user] from convertToDM).

Added two test cases for the tie-breaker path.

mostFrequentMember uses map iteration to find the current user among
DM members.  When there is only one DM (or a tie in frequency counts),
Go's non-deterministic map ordering can pick either member, causing
the viewer to display the current user's name instead of the other
person's name.

Break the tie by selecting the last member of the first DM entry,
which matches slackdump's export ordering of [other_user, current_user].
@rusq
Copy link
Copy Markdown
Owner

rusq commented Mar 29, 2026

Hey @shehrozsheikh , thanks for the fix. I added a normalisation to ensure that "me" always stays last at the time when "me" is known.

@rusq rusq merged commit d737d73 into rusq:master Mar 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Viewer shows current user's name instead of the other person for DMs

2 participants