feat(profile): keep_screen_awake user preference (default on)

New users column surfaced as an On/Off dropdown in the profile form.
The form and API carry "true"/"false" strings with the theme-style
""-guard, so JSON clients that omit the field can't clobber it;
anything else is rejected. GET/PUT /api/auth/profile expose
keep_screen_awake alongside the other profile fields, and the reader
route threads the preference into its template metadata.

Integration tests pin the schema default, both values, omission
semantics, and rejection — dedicated test user, never testuser.
This commit is contained in:
John O'Keefe committed 2026-10-26 13:59:32 -04:00
1 parent bdb9132b85
commit c645b8e207
12 files changed
+244 -67

No files matched your search

+19 -1
View File
@@ -9942,6 +9942,7 @@ SELECT
u.updated_at,
u.timezone,
u.default_audio_speed,
u.keep_screen_awake,
(SELECT COUNT(*) FROM devices WHERE user_id = u.id) as device_count
FROM users u
WHERE u.id = $1
@@ -9960,6 +9961,7 @@ type GetUserRow struct {
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
Timezone pgtype.Text `db:"timezone" json:"timezone"`
DefaultAudioSpeed float32 `db:"default_audio_speed" json:"default_audio_speed"`
KeepScreenAwake bool `db:"keep_screen_awake" json:"keep_screen_awake"`
DeviceCount int64 `db:"device_count" json:"device_count"`
}
@@ -9979,6 +9981,7 @@ func (q *Queries) GetUser(ctx context.Context, id pgtype.UUID) (GetUserRow, erro
&i.UpdatedAt,
&i.Timezone,
&i.DefaultAudioSpeed,
&i.KeepScreenAwake,
&i.DeviceCount,
)
return i, err
@@ -17236,9 +17239,23 @@ func (q *Queries) UpdateUserDefaultAudioSpeed(ctx context.Context, arg UpdateUse
return err
}
const UpdateUserKeepScreenAwake = `-- name: UpdateUserKeepScreenAwake :exec
UPDATE users SET keep_screen_awake = $2, updated_at = NOW() WHERE id = $1
`
type UpdateUserKeepScreenAwakeParams struct {
ID pgtype.UUID `db:"id" json:"id"`
KeepScreenAwake bool `db:"keep_screen_awake" json:"keep_screen_awake"`
}
func (q *Queries) UpdateUserKeepScreenAwake(ctx context.Context, arg UpdateUserKeepScreenAwakeParams) error {
_, err := q.db.Exec(ctx, UpdateUserKeepScreenAwake, arg.ID, arg.KeepScreenAwake)
return err
}
const UpdateUserMaxDevices = `-- name: UpdateUserMaxDevices :one
UPDATE users SET max_devices = $2, updated_at = NOW() WHERE id = $1
RETURNING id, email, username, password_hash, first_name, last_name, role, theme, max_devices, created_at, timezone, updated_at, default_audio_speed
RETURNING id, email, username, password_hash, first_name, last_name, role, theme, max_devices, created_at, timezone, updated_at, default_audio_speed, keep_screen_awake
`
type UpdateUserMaxDevicesParams struct {
@@ -17263,6 +17280,7 @@ func (q *Queries) UpdateUserMaxDevices(ctx context.Context, arg UpdateUserMaxDev
&i.Timezone,
&i.UpdatedAt,
&i.DefaultAudioSpeed,
&i.KeepScreenAwake,
)
return i, err
}