Repository navigation
Refactor codebase for improved structure and shared logic - #7
Merged
Merged
Conversation
`eslint .` descended into .claude/worktrees/*/.next and reported 30,161 problems from generated chunks, burying every real one. The existing ignore globs are root-anchored, so they never matched the nested copies.
The 3-24 character rule was written out five times: twice in validation.ts as an identical regex and message, and three more as HTML pattern attributes. signUpSchema now reuses usernameSchema, and USERNAME_PATTERN feeds the three inputs, so the rule has one definition to change.
The select, its two filters and the flattening of the joined profile row were written out identically on the server (chat page) and in the browser (realtime refresh). fetchPendingRequests takes whichever Supabase client the caller already holds, so both sides run the same query.
The avatar/image/initial-fallback block was copied at four call sites, varying only in size classes. One component now covers all four.
The avatar and attachment pickers ran the same size-then-type sequence with the same comment above it, differing only in limits and wording. Those now live beside the limits they enforce, as ATTACHMENT_RULE and AVATAR_RULE.
Channel bookkeeping -- setAuth, per-conversation subscribe, presence, teardown -- was ~150 lines in the middle of a component that also renders a sidebar. useConversationChannels and useFriendNotifications now own it. Two things fall out. setTyping takes a conversation id, so the shell no longer reaches through a channel map to call track() on an object it should not know about. And the handlers are held in refs updated after commit, so the subscription depends only on the client, the user and the conversation ids; previously a handler identity change could rebuild every channel.
The sidebar list was inline markup with no logic of its own. Moving it leaves chat-shell reading as state, actions, layout.
It still described login/signup at the app root and predated the site pages. Adds the conventions a new file has to follow to stay consistent.
The paperclip opened the OS dialog straight away with every permitted type at once, so the list mixed photos, PDFs and zips and nothing said what was allowed until an upload was rejected. It now opens a popover -- Photo, Document, Archive -- and the choice narrows the input's accept before the dialog opens. The groups are the source ATTACHMENT_MIME is flattened from, so the allowlist and the bucket's stay one list. accept is only a hint, so checkFile is still the gate. The attribute is set on the node rather than through state: React would not flush a re-render before .click(), and the dialog would open with the last filter.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
No description provided.