Skip to content

Commit

Permalink
Cleaned up user display name showing. Version update
Browse files Browse the repository at this point in the history
  • Loading branch information
DaltonSW committed Aug 22, 2024
1 parent dc6717e commit 1102bbf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ If you choose to use the environment variable method, make sure to include a lin

From there, you should be good to go! If you installed the CLI program, you can run `aocli health` to verify that everything loaded properly.
![aocli health](./assets/aocliHealth.png)


## Licensing

© 2024 Dalton Williams
Check repository LICENSE file for licensing information.
13 changes: 7 additions & 6 deletions cmd/aocli/aocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func main() {
// run(args)
case "view":
View(args, user)
case "test":
test(user)
// case "test":
// test(user)
case "user":
User(args, user)
case "clear-user":
Expand Down Expand Up @@ -412,7 +412,8 @@ func Health() {

// Test does whatever I need to test at the time :)
// Command: `aocli test`
func test(user *resources.User) {
user.LoadDisplayName()
log.Info(user.DisplayName)
}
// func test(user *resources.User) {
// dispName := user.LoadDisplayName()
// log.Info(user.DisplayName)
// log.Info(dispName)
// }
2 changes: 1 addition & 1 deletion cmd/aocli/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

// Internally tracked version to compare against GitHub releases
const currentVersion = "v0.9.7"
const currentVersion = "v0.9.8"
const repoURL = "https://api.github.com/repos/DaltonSW/aocGo/releases/latest"

type githubRelease struct {
Expand Down
14 changes: 9 additions & 5 deletions internal/resources/User.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ func NewUser(token string) (*User, error) {
yearMap[i] = make([]*Puzzle, 26)
}

return &User{
newUser := &User{
SessionTok: token,
Years: yearMap,
}, nil
}

name := newUser.LoadDisplayName()
newUser.DisplayName = name

return newUser, nil
}

func (u *User) Display() {
Expand All @@ -70,7 +75,6 @@ func (u *User) Display() {
}

func (u *User) LoadUser() {
u.LoadDisplayName()
maxYear, _ := utils.GetCurrentMaxYearAndDay()

numStars := make(map[int]int)
Expand Down Expand Up @@ -104,7 +108,7 @@ func (u *User) LoadUser() {
}
}

func (u *User) LoadDisplayName() {
func (u *User) LoadDisplayName() string {
resp, err := api.NewGetReq("https://adventofcode.com/", u.SessionTok)
if err != nil {
log.Fatal("Unable to load user's information", "err", err)
Expand All @@ -124,5 +128,5 @@ func (u *User) LoadDisplayName() {
// log.Info(nameClone.Text())
nameClone.Find("span").Remove()

u.DisplayName = strings.TrimSpace(nameClone.Text())
return strings.TrimSpace(nameClone.Text())
}
13 changes: 5 additions & 8 deletions internal/resources/UserView.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@ func (u *User) NewModel() tea.Model {
s.Spinner.FPS = 20
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color(styles.UpdateSpinnerColor))

u.LoadDisplayName()

model := LoadUserModel{
user: u,
userName: u.DisplayName,
spinner: s,
curYear: utils.FIRST_YEAR,
curDate: 1,
status: "Starting up!",
user: u,
spinner: s,
curYear: utils.FIRST_YEAR,
curDate: 1,
status: "Starting up!",
}

return model
Expand Down

0 comments on commit 1102bbf

Please sign in to comment.