fix pattern and role bugs (#1343)

## Description:

1. this.cosmetics.role_groups[groupName] was undefined causing an error
2. When logging out, reset the pattern. This was causing an unauthorized
pattern error because it persisted after log out.


## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

evan
This commit is contained in:
evanpelle
2025-07-04 13:13:19 -07:00
committed by GitHub
parent 7a3a3a59e8
commit 0fed0e96f9
3 changed files with 10 additions and 5 deletions
+4 -4
View File
@@ -182,13 +182,13 @@ class Client {
const territoryModal = document.querySelector(
"territory-patterns-modal",
) as TerritoryPatternsModal;
const tpButton = document.getElementById(
const patternButton = document.getElementById(
"territory-patterns-input-preview-button",
);
territoryModal instanceof TerritoryPatternsModal;
if (tpButton === null)
if (patternButton === null)
throw new Error("territory-patterns-input-preview-button");
territoryModal.previewButton = tpButton;
territoryModal.previewButton = patternButton;
territoryModal.updatePreview();
territoryModal.resizeObserver = new ResizeObserver((entries) => {
for (const entry of entries) {
@@ -197,7 +197,7 @@ class Client {
}
}
});
tpButton.addEventListener("click", () => {
patternButton.addEventListener("click", () => {
territoryModal.open();
});
+5
View File
@@ -64,6 +64,11 @@ export class TerritoryPatternsModal extends LitElement {
async onUserMe(userMeResponse: UserMeResponse | null) {
this.patterns = await patterns(userMeResponse);
const p = this.patterns.find((p) => p.name === this.selectedPattern);
if (p === undefined || p.lockedReason || p.notShown) {
console.warn("selected pattern is locked or not shown, resetting");
this.selectPattern(undefined);
}
this.me = userMeResponse;
this.requestUpdate();
}
+1 -1
View File
@@ -40,7 +40,7 @@ export class PrivilegeChecker {
if (
roles !== undefined &&
roles.some((role) =>
this.cosmetics.role_groups[groupName].includes(role),
this.cosmetics.role_groups[groupName]?.includes(role),
)
) {
// Player is in a role group for this pattern