feat: added '2 step confirm' for allience breakage#3150
feat: added '2 step confirm' for allience breakage#3150RjManhas wants to merge 6 commits intoopenfrontio:mainfrom
Conversation
WalkthroughAdds a confirm-break-alliance flow: new modal component, localization keys, user setting and UI toggle, two transport events and Transport constructor change to accept userSettings, renderer wiring for the modal, and execution guard when no alliance exists. (≤50 words) Changes
Sequence DiagramsequenceDiagram
participant User
participant Transport
participant EventBus
participant Modal as ConfirmBreakAllianceModal
participant Game
participant Execution
User->>Transport: SendBreakAllianceIntentEvent
Transport->>Transport: check userSettings.confirmBreakAlliance()
alt setting enabled
Transport->>EventBus: emit RequestConfirmBreakAllianceEvent
EventBus->>Modal: deliver RequestConfirmBreakAllianceEvent
Modal->>User: display confirmation dialog
User->>Modal: click Confirm
Modal->>Modal: validate game state & alliance
Modal->>EventBus: emit ConfirmedBreakAllianceIntentEvent
EventBus->>Transport: deliver ConfirmedBreakAllianceIntentEvent
Transport->>Game: send break alliance intent
else setting disabled
Transport->>Game: send break alliance intent
end
Game->>Execution: execute break alliance
Execution->>Execution: check alliance exists
alt alliance found
Execution->>Game: break alliance, update relations
else no alliance
Execution->>Execution: disable action, return early
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/client/graphics/layers/ConfirmBreakAllianceModal.ts`:
- Around line 48-59: The updated method currently only subscribes when eventBus
becomes available but never unsubscribes the previous bus if eventBus is
replaced; modify updated to detect when changed.has("eventBus") and, if
this._subscribed is true and this.eventBus !== previousEventBus, call the old
bus's unsubscribe method (e.g., eventBus.off or removeListener) for
RequestConfirmBreakAllianceEvent with this.requestConfirmHandler before
assigning the new bus, then subscribe the new bus and ensure this._subscribed
reflects the current subscription; update logic in the updated method and use
the unique symbols updated, eventBus, _subscribed, and requestConfirmHandler to
locate and apply the change.
🧹 Nitpick comments (3)
src/client/UserSettingModal.ts (1)
822-830: Missingidattribute on the setting toggle.Other
setting-toggleelements in this file have anid(e.g.,"alert-frame-toggle","emoji-toggle"). This one is missing it. Add one for consistency and potential future DOM queries.Suggested fix
<setting-toggle label="${translateText("user_setting.confirm_break_alliance_label")}" description="${translateText( "user_setting.confirm_break_alliance_desc", )}" + id="confirm-break-alliance-toggle" .checked=${this.userSettings.confirmBreakAlliance()} `@change`=${this.toggleConfirmBreakAlliance} ></setting-toggle>src/client/graphics/layers/ConfirmBreakAllianceModal.ts (2)
33-35: EmptyconnectedCallbackcan be removed.This override does nothing beyond calling
super.connectedCallback(). LitElement already calls it. Safe to delete these three lines.Proposed cleanup
- connectedCallback() { - super.connectedCallback(); - } -
20-25:requestUpdate()calls are redundant when mutating@stateproperties.In LitElement, setting a
@state()decorated property automatically schedules an update. The explicitthis.requestUpdate()on Lines 24 and 71 is unnecessary.Proposed cleanup
private requestConfirmHandler = (e: RequestConfirmBreakAllianceEvent) => { this.requestor = e.requestor; this.recipient = e.recipient; this.open = true; - this.requestUpdate(); };private closeModal() { this.open = false; this.recipient = null; this.requestor = null; - this.requestUpdate(); }Also applies to: 67-72
…ontIO into confirm-betrayal pushed
|
@evanpelle when you are free, please review this |
Resolves:
https://discord.com/channels/1284581928254701718/1466749482170454192
https://discord.com/channels/1284581928254701718/1384910711788146779 (some what, they want a more general confirm system)
https://discord.com/channels/1284581928254701718/1384543980414570607
https://discord.com/channels/1284581928254701718/1341874291452411915
Description:
A toggle able setting which is disabled by default, which will when enabled show a modal popup to confirm that you want to attack someone that who you are allied with.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
notifxy (1379678982676676639 )