Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/client/graphics/layers/WinModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export class WinModal extends LitElement implements Layer {
@state()
private patternContent: TemplateResult | null = null;

@state()
private hasDiscord = false;

private _title: string;

private rand = Math.random();
Expand Down Expand Up @@ -116,7 +119,10 @@ export class WinModal extends LitElement implements Layer {
if (this.rand < 0.25) {
return this.steamWishlist();
} else if (this.rand < 0.5) {
return this.discordDisplay();
// If user already has Discord, don't show the "join Discord" promo
return this.hasDiscord
? this.renderPatternButton()
: this.discordDisplay();
} else {
return this.renderPatternButton();
}
Expand Down Expand Up @@ -160,6 +166,7 @@ export class WinModal extends LitElement implements Layer {
async loadPatternContent() {
const me = await getUserMe();
const patterns = await fetchCosmetics();
this.hasDiscord = me !== false && me.user.discord !== undefined;
Comment on lines 166 to +169
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, check if the file exists and read context around the specific lines
echo "=== Reading WinModal.ts context (lines 160-175) ==="
wc -l src/client/graphics/layers/WinModal.ts
sed -n '160,175p' src/client/graphics/layers/WinModal.ts

echo -e "\n=== Searching for Discord server/membership logic ==="
rg -n "discord" --type=ts -i | grep -i "member\|guild\|server\|openfront" | head -20

echo -e "\n=== Searching for broader patterns around hasDiscord usage ==="
rg -n "hasDiscord" --type=ts -C3

echo -e "\n=== Looking for guild or server membership checks ==="
rg -n "guild\|membership\|member.*server" --type=ts -i | head -20

Repository: openfrontio/OpenFrontIO

Length of output: 2346


🏁 Script executed:

#!/bin/bash
# Check issue `#3093` references or comments in code
echo "=== Searching for issue `#3093` or related promo/membership logic ==="
rg -n "3093\|Openfront.*community\|community.*server" --type=ts -i

echo -e "\n=== Checking how getUserMe() is used and what it returns ==="
rg -n "getUserMe|user\.discord" --type=ts -B2 -A2 | head -40

Repository: openfrontio/OpenFrontIO

Length of output: 2804


The code checks only if Discord is linked, not if the user is a server member.

The current implementation at line 169 sets hasDiscord based on me.user.discord !== undefined, which indicates a linked Discord account. However, issue #3093 requires hiding the promo if the user "is already a member of the Openfront community server." These are not the same—linking Discord does not guarantee server membership.

No explicit server membership verification exists in the codebase. Either:

  1. The app's flow implicitly guarantees that linking Discord means the user is already in the server, or
  2. An explicit membership check is needed (e.g., via Discord API or stored membership flag)

Clarify which behavior is intended and update the implementation if needed.

🤖 Prompt for AI Agents
In `@src/client/graphics/layers/WinModal.ts` around lines 166 - 169, The current
loadPatternContent() sets this.hasDiscord using me.user.discord !== undefined
which only detects a linked Discord account, not server membership; update
loadPatternContent (and related logic that uses this.hasDiscord) to verify
actual Openfront server membership instead of just a linked account — either by
reading a dedicated membership flag returned by getUserMe() (e.g.,
me.user.isOpenfrontMember or similar) or by adding a new API call that checks
membership (e.g., checkDiscordServerMembership(userId) or a backend endpoint)
and set this.hasDiscord only when that membership check succeeds; ensure you
adjust any downstream UI usage to rely on the membership check rather than
me.user.discord.


const purchasablePatterns: {
pattern: Pattern;
Expand Down
Loading