Skip to content

Commit b26b2a0

Browse files
committed
Switch to tea.Sequentially
1 parent 831847c commit b26b2a0

File tree

4 files changed

+8
-24
lines changed

4 files changed

+8
-24
lines changed

db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (db *db) save() error {
4949
if err != nil {
5050
return errors.Wrap(err, "could not serialize database")
5151
}
52-
if err := maybe.WriteFile(dbPath, data, 0o644); err != nil {
52+
if err := maybe.WriteFile(dbPath, data, 0644); err != nil {
5353
return errors.Wrapf(err, "could not write to database: %s", dbPath)
5454
}
5555
return nil

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.13
44

55
require (
66
github.com/adrg/xdg v0.4.0
7-
github.com/charmbracelet/bubbletea v0.19.4-0.20220131220437-77e63ac89037
7+
github.com/charmbracelet/bubbletea v0.19.4-0.20220202015352-c5d3b1e1544a
88
github.com/charmbracelet/lipgloss v0.4.0
99
github.com/google/renameio v1.0.1
1010
github.com/pkg/errors v0.9.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
22
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
3-
github.com/charmbracelet/bubbletea v0.19.4-0.20220131220437-77e63ac89037 h1:dlKlZNPkKgzCW/LeNGY9Al3qOGBiUOy+2Axs5bZS5KY=
4-
github.com/charmbracelet/bubbletea v0.19.4-0.20220131220437-77e63ac89037/go.mod h1:5nPeULOIxbAMykb3ggwhw1kruS7nP+Y4Za9yEH4J27U=
3+
github.com/charmbracelet/bubbletea v0.19.4-0.20220202015352-c5d3b1e1544a h1:D4RqRJSEKvggU+aCND2Q/5y/eGpecrJ0QYUcqK4kdp4=
4+
github.com/charmbracelet/bubbletea v0.19.4-0.20220202015352-c5d3b1e1544a/go.mod h1:5nPeULOIxbAMykb3ggwhw1kruS7nP+Y4Za9yEH4J27U=
55
github.com/charmbracelet/lipgloss v0.4.0 h1:768h64EFkGUr8V5yAKV7/Ta0NiVceiPaV+PphaW1K9g=
66
github.com/charmbracelet/lipgloss v0.4.0/go.mod h1:vmdkHvce7UzX6xkyf4cca8WlwdQ5RQr8fzta+xl7BOM=
77
github.com/containerd/console v1.0.2 h1:Pi6D+aZXM+oUw1czuKgH5IJ+y0jhYcwBJfx5/Ghn9dE=

model.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (m *model) doDeleteChar() tea.Cmd {
215215
}
216216

217217
// doExit exits the program.
218-
func (m *model) doExit() tea.Cmd {
218+
func (*model) doExit() tea.Cmd {
219219
return tea.Quit
220220
}
221221

@@ -229,7 +229,7 @@ func (m *model) doResize(msg tea.WindowSizeMsg) tea.Cmd {
229229
// doWin is called when the user has guessed the word correctly.
230230
func (m *model) doWin() tea.Cmd {
231231
m.gameOver = true
232-
return sequentially(
232+
return tea.Sequentially(
233233
m.withDb(func(db *db) {
234234
db.addWin(m.gridRow)
235235
m.score = db.score()
@@ -242,7 +242,7 @@ func (m *model) doWin() tea.Cmd {
242242
func (m *model) doLoss() tea.Cmd {
243243
m.gameOver = true
244244
msg := fmt.Sprintf("The word was %s. Better luck next time!", string(m.word[:]))
245-
return sequentially(
245+
return tea.Sequentially(
246246
m.withDb(func(db *db) {
247247
db.addLoss()
248248
m.score = db.score()
@@ -353,7 +353,7 @@ func (m *model) viewKeyboardRow(keys []string) string {
353353
}
354354

355355
// viewKey renders a key with the given name and color.
356-
func (_ *model) viewKey(key string, color lipgloss.TerminalColor) string {
356+
func (*model) viewKey(key string, color lipgloss.TerminalColor) string {
357357
return lipgloss.NewStyle().
358358
Padding(0, 1).
359359
Border(lipgloss.NormalBorder()).
@@ -418,22 +418,6 @@ func (s keyState) color() lipgloss.Color {
418418
}
419419
}
420420

421-
// FIXME: replace with tea.Sequentially
422-
// https://github.com/charmbracelet/bubbletea/pull/214
423-
func sequentially(cmds ...tea.Cmd) tea.Cmd {
424-
return func() tea.Msg {
425-
for _, cmd := range cmds {
426-
if cmd == nil {
427-
continue
428-
}
429-
if msg := cmd(); msg != nil {
430-
return msg
431-
}
432-
}
433-
return nil
434-
}
435-
}
436-
437421
// isAsciiUpper checks if a rune is between A-Z.
438422
func isAsciiUpper(r rune) bool {
439423
return 'A' <= r && r <= 'Z'

0 commit comments

Comments
 (0)