Skip to content

refactor: clean code phase 2 — file splits and DRY fixes#116

Merged
alexneamtu merged 21 commits intomainfrom
refactor/clean-code-phase1
Mar 10, 2026
Merged

refactor: clean code phase 2 — file splits and DRY fixes#116
alexneamtu merged 21 commits intomainfrom
refactor/clean-code-phase1

Conversation

@alexneamtu
Copy link
Contributor

Summary

  • Split sso/handler.go (1124 lines) into protocol-specific files: handler.go, handler_oidc.go, handler_saml.go
  • Split VideoDetail.tsx (2088 lines) into VideoDetail/ with 4 sub-components
  • Split Settings.tsx (1923 lines) into Settings/ with 9 files
  • Split OrgSettings.tsx (1237 lines) into OrgSettings/ with 7 files
  • Split Analytics.tsx (920 lines) into Analytics/ with 8 files
  • Split PlaylistDetail.tsx (960 lines) into PlaylistDetail/ with 3 files
  • Split Library.tsx (893 lines) into Library/ with 3 files
  • Removed 5 duplicated formatTime/formatTimestamp functions, replaced with shared formatDuration
  • Extracted shared playlist JS and loadPlaylistVideos helper
  • Deduplicated billing handlers with parameterized entity helpers
  • Extracted useRecording hook, useToast hook, ConfirmDialog component, shared types/utils

Test plan

  • All 733 frontend tests pass
  • All Go tests pass (go test ./...)
  • TypeScript typecheck clean
  • Go build clean

Add RetentionDays validator to the validate package and remove the
duplicate inline validRetentionDays map from organization.go. Also
add Password validator and corresponding tests in preparation for
deduplicating the three password validation blocks in auth.go.
Replace the three duplicate password length checks in auth.go
(Register, ResetPassword, UpdateUser) with validate.Password calls,
and replace the inline validRetentionDays map with validate.RetentionDays.
Creates web/src/types/video.ts with canonical Video, VideoTag, Folder, and
Tag interfaces. Removes duplicate inline declarations from VideoDetail.tsx and
Library.tsx. VideoDetail-only fields (document, documentStatus,
transcriptionLanguage, noiseReduction, playlists) are marked optional so
Library can safely use the same type without carrying unused fields.
…rd to shared utils

Creates web/src/utils/format.ts with formatDuration, formatDate, formatChartDate,
and expiryLabel, and web/src/utils/clipboard.ts with copyToClipboard. Removes all
inline duplicate definitions from VideoDetail.tsx, Library.tsx, PlaylistDetail.tsx,
Playlists.tsx, Analytics.tsx, Recorder.tsx, and CameraRecorder.tsx, replacing them
with imports from the new shared modules.
Extract SharingSection, TranscriptSection, and CommentsSection from
the 2088-line VideoDetail.tsx into a VideoDetail/ directory with an
index.tsx orchestrator and three focused sub-components.
Break up the 1923-line Settings.tsx into Settings/ directory with
index.tsx orchestrator plus 7 section components and shared types.
Break up the 1237-line OrgSettings.tsx into OrgSettings/ directory
with index.tsx orchestrator plus 4 section components and shared types.
…ormatDuration

Remove 5 identical time-formatting functions from TrimModal,
FillerRemovalModal, SilenceRemovalModal, CommentsSection, and
TranscriptSection — all replaced with existing formatDuration from
utils/format.ts.
Split the 1124-line handler.go into handler.go (shared utilities,
identity/SCIM management), handler_oidc.go (OIDC flows), and
handler_saml.go (SAML flows).
…nents

Analytics.tsx (920 lines) → Analytics/ with 8 files.
PlaylistDetail.tsx (960 lines) → PlaylistDetail/ with 3 files.
Library.tsx (893 lines) → Library/ with 3 files.
@github-actions
Copy link

Preview deployed: https://pr-116.app.sendrec.eu

@alexneamtu alexneamtu merged commit c84ef0c into main Mar 10, 2026
10 checks passed
@alexneamtu alexneamtu deleted the refactor/clean-code-phase1 branch March 10, 2026 18:29
@github-actions
Copy link

Preview environment cleaned up.

@alexneamtu alexneamtu self-assigned this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant