fix: fetch server configuration on client initialization for invite_only servers#152
Open
riscdanger wants to merge 1 commit intostoatchat:mainfrom
Open
fix: fetch server configuration on client initialization for invite_only servers#152riscdanger wants to merge 1 commit intostoatchat:mainfrom
riscdanger wants to merge 1 commit intostoatchat:mainfrom
Conversation
The Client constructor sets `configured` to true and skips fetching the real server config when a default configuration is pre-set by the Controller. This caused `invite_only` and other feature flags to always reflect hardcoded defaults instead of actual server values. Introduce a `#configurationFetched` flag to track whether the server config has been fetched, independent of whether a default config was provided. The `configured` signal now starts as false and is set to true only after the real config is retrieved. Fixes: invite-only registration form not showing the invite code field Signed-off-by: risc <dev@risc.4wrd.cc>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When invite_only: true is set on a Stoat server, the registration form in the web frontend never displays the "Invite Code" input field, making it impossible to register on invite-only instances via the UI.
note: I'm not a typescript dev and this was written by AI.
Thanks :)
Root Cause
The Client constructor in
javascript-client-sdk/src/Client.tsinitializes configured to true whenever a default configuration is passed in (whichController.tsalways does). The#fetchConfiguration()method then skips fetching the real server config becausethis.configurationis already truthy.As a result,
features.invite_onlywas always false (the hardcoded default), soFlowCreate.tsx's<Show when={isInviteOnly()}>never rendered the invite field.Changes
javascript-client-sdk/src/Client.ts#configurationFetchedflag to track whether the server config has been fetched#fetchConfiguration()now always fetches the real server config on first call, then cachesThe frontend code in
FlowCreate.tsxandForm.tsxwas already correct — it just never received the real server config to read invite_only from.Testing