1
0
Fork 0

Moved loadPost into main file

This commit is contained in:
マリウス 2023-01-03 16:47:17 -05:00
parent 36a47727c7
commit c69287482e
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F
2 changed files with 23 additions and 22 deletions

View File

@ -123,25 +123,3 @@ func handleWinFreshDataCmd(mi interface{}, c cmd.Command) (bool, []tea.Cmd) {
return false, cmds
}
func (m *Model) loadPost(p *post.Post) tea.Cmd {
return func() tea.Msg {
m.ctx.Logger.Debug("------ EXECUTED -----")
if err := m.a.LoadPost(p); err != nil {
m.ctx.Logger.Error(err)
c := cmd.New(
cmd.MsgError,
WIN_ID,
cmd.Arg{Name: "error", Value: err},
)
return *c
}
c := cmd.New(
cmd.WinFreshData,
WIN_ID,
cmd.Arg{Name: "post", Value: p},
)
return *c
}
}

View File

@ -8,6 +8,7 @@ import (
"github.com/mrusme/gobbs/aggregator"
"github.com/mrusme/gobbs/models/post"
"github.com/mrusme/gobbs/models/reply"
"github.com/mrusme/gobbs/ui/cmd"
"github.com/mrusme/gobbs/ui/ctx"
"github.com/mrusme/gobbs/ui/toolkit"
)
@ -96,3 +97,25 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Batch(cmds...)
}
func (m *Model) loadPost(p *post.Post) tea.Cmd {
return func() tea.Msg {
m.ctx.Logger.Debug("------ EXECUTED -----")
if err := m.a.LoadPost(p); err != nil {
m.ctx.Logger.Error(err)
c := cmd.New(
cmd.MsgError,
WIN_ID,
cmd.Arg{Name: "error", Value: err},
)
return *c
}
c := cmd.New(
cmd.WinFreshData,
WIN_ID,
cmd.Arg{Name: "post", Value: p},
)
return *c
}
}