If user has no linked account, ensure that their skin is set to default

This commit is contained in:
evanpelle
2025-12-11 12:18:06 -08:00
parent a09f0c67f1
commit 01e5aaa832
2 changed files with 14 additions and 12 deletions
+11
View File
@@ -131,3 +131,14 @@ export function getAudience() {
const domainname = hostname.split(".").slice(-2).join(".");
return domainname;
}
// Check if the user's account is linked to a Discord or email account.
export function hasLinkedAccount(
userMeResponse: UserMeResponse | false,
): boolean {
return (
userMeResponse !== false &&
(userMeResponse.user?.discord !== undefined ||
userMeResponse.user?.email !== undefined)
);
}
+3 -12
View File
@@ -5,6 +5,7 @@ import { UserMeResponse } from "../core/ApiSchemas";
import { ColorPalette, Cosmetics, Pattern } from "../core/CosmeticSchemas";
import { UserSettings } from "../core/game/UserSettings";
import { PlayerPattern } from "../core/Schemas";
import { hasLinkedAccount } from "./Api";
import "./components/Difficulties";
import "./components/PatternButton";
import { renderPatternPreview } from "./components/PatternButton";
@@ -55,7 +56,7 @@ export class TerritoryPatternsModal extends LitElement {
}
async onUserMe(userMeResponse: UserMeResponse | false) {
if (userMeResponse === false) {
if (!hasLinkedAccount(userMeResponse)) {
this.userSettings.setSelectedPatternName(undefined);
this.selectedPattern = null;
this.selectedColor = null;
@@ -134,7 +135,7 @@ export class TerritoryPatternsModal extends LitElement {
return html`
<div class="flex flex-col gap-2">
<div class="flex justify-center">
${this.isLoggedIn()
${hasLinkedAccount(this.userMeResponse)
? this.renderMySkinsButton()
: this.renderNotLoggedInWarning()}
</div>
@@ -290,14 +291,4 @@ export class TerritoryPatternsModal extends LitElement {
render(preview, this.previewButton);
this.requestUpdate();
}
private isLoggedIn(): boolean {
if (this.userMeResponse === false) {
return false;
}
return (
this.userMeResponse.user.discord !== undefined ||
this.userMeResponse.user.email !== undefined
);
}
}