Monorepo for Tangled
0

Configure Feed

Select the types of activity you want to include in your feed.

appview/models: add onboarding stages and model

Signed-off-by: oppiliappan <me@oppi.li>

oppiliappan (Jul 7, 2026, 3:55 PM +0100) 161c85b9 6c053c32

+60
+60
appview/models/onboarding.go
··· 1 + package models 2 + 3 + import ( 4 + "time" 5 + ) 6 + 7 + type OnboardingStatus string 8 + 9 + const ( 10 + OnboardingInProgress OnboardingStatus = "in_progress" 11 + OnboardingCompleted OnboardingStatus = "completed" 12 + OnboardingSkipped OnboardingStatus = "skipped" 13 + ) 14 + 15 + // onboarding steps, in order. Done is a sentinel that marks completion. 16 + const ( 17 + OnboardingStepProfile = 0 18 + OnboardingStepSocial = 1 19 + OnboardingStepKeys = 2 20 + OnboardingStepRepo = 3 21 + OnboardingStepDone = 4 22 + ) 23 + 24 + type Onboarding struct { 25 + Did string 26 + Step int 27 + Status OnboardingStatus 28 + Created time.Time 29 + Updated time.Time 30 + } 31 + 32 + // OnboardingProgress feeds the "resume onboarding" banner/panel. Active is false 33 + // when there is nothing to resume (no in-progress onboarding). 34 + type OnboardingProgress struct { 35 + Active bool 36 + Step int 37 + Total int 38 + Percent int 39 + } 40 + 41 + // Progress derives display progress for the resume banner/panel. It is nil-safe, 42 + // so callers can pass the result of GetOnboarding directly. 43 + func (o *Onboarding) Progress() OnboardingProgress { 44 + if o == nil || o.Status != OnboardingInProgress { 45 + return OnboardingProgress{} 46 + } 47 + // Percent reflects completed steps out of the total, so the bar only fills 48 + // as steps are finished (e.g. on the last step it is not yet 100%). 49 + total := OnboardingStepDone 50 + percent := o.Step * 100 / total 51 + if percent > 100 { 52 + percent = 100 53 + } 54 + return OnboardingProgress{ 55 + Active: true, 56 + Step: o.Step, 57 + Total: total, 58 + Percent: percent, 59 + } 60 + }