Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -15,9 +15,7 @@ import (
|
||||
|
||||
// CreateBox is the resolver for the createBox field.
|
||||
func (r *mutationResolver) CreateBox(ctx context.Context, input model.CreateBoxInput) (*models.Box, error) {
|
||||
// Framed defaults to true here rather than in the gorm tag — see the
|
||||
// comment on models.Box.Framed. Sizes not supplied fall back to the
|
||||
// same 300x200 the column defaults use.
|
||||
// Framed defaults here, not in the gorm tag; see models.Box.Framed.
|
||||
box := models.Box{
|
||||
Page: input.Page,
|
||||
Kind: input.Kind,
|
||||
@@ -45,8 +43,7 @@ func (r *mutationResolver) CreateBox(ctx context.Context, input model.CreateBoxI
|
||||
if input.AdminOnly != nil {
|
||||
box.AdminOnly = *input.AdminOnly
|
||||
}
|
||||
// A linked box takes its html from the component, so its own is
|
||||
// dropped rather than stored as a copy that would quietly go stale.
|
||||
// A linked box's own html would only go stale.
|
||||
if input.ComponentID != nil {
|
||||
id := uint(*input.ComponentID)
|
||||
exists, err := componentExists(r.Store.DB, id)
|
||||
@@ -75,10 +72,8 @@ func (r *mutationResolver) CreateBox(ctx context.Context, input model.CreateBoxI
|
||||
|
||||
// UpdateBox is the resolver for the updateBox field.
|
||||
func (r *mutationResolver) UpdateBox(ctx context.Context, id int, input model.UpdateBoxInput) (*models.Box, error) {
|
||||
// Partial update: nil fields are left alone. The canvas sends only the
|
||||
// geometry after a drag and only the html after an edit, so this is
|
||||
// what keeps the two from overwriting each other. Kind is not
|
||||
// updatable — switching a widget box to html is a delete and create.
|
||||
// Partial: the canvas sends only geometry after a drag and only html after
|
||||
// an edit, so neither overwrites the other.
|
||||
var box models.Box
|
||||
if err := r.Store.DB.First(&box, id).Error; err != nil {
|
||||
return nil, err
|
||||
@@ -87,8 +82,7 @@ func (r *mutationResolver) UpdateBox(ctx context.Context, id int, input model.Up
|
||||
box.Widget = input.Widget
|
||||
}
|
||||
if input.HTML != nil {
|
||||
// A linked box's html is the component's; changing it here would
|
||||
// only fork a copy. The editor sends it to updateComponent instead.
|
||||
// Edit linked html via updateComponent, or it forks a copy.
|
||||
if box.ComponentID != nil {
|
||||
return nil, errors.New("that box is linked to a component: edit the component, or detach the box first")
|
||||
}
|
||||
@@ -140,12 +134,8 @@ func (r *mutationResolver) DeleteBox(ctx context.Context, id int) (*models.Box,
|
||||
|
||||
// Boxes is the resolver for the boxes field.
|
||||
func (r *queryResolver) Boxes(ctx context.Context, page string) ([]*models.Box, error) {
|
||||
// Public: this is the page layout every visitor loads. Ordered by z so
|
||||
// DOM order matches stacking order, which keeps tab order sensible.
|
||||
//
|
||||
// What is admin-only is filtered here rather than hidden in the browser,
|
||||
// so a private note never reaches anyone else: an adminOnly page answers
|
||||
// with no boxes at all, and adminOnly boxes are left out of the rest.
|
||||
// Ordered by z so DOM and tab order match stacking. Admin-only content is
|
||||
// filtered server-side so it never reaches anyone else.
|
||||
hidden, err := pageHiddenFrom(ctx, r.Store.DB, page)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user