mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-09-29 04:45:55 -04:00
Enabled viewcache for postshow
This commit is contained in:
parent
d9c07422d6
commit
02a88f4ee9
@ -56,6 +56,8 @@ type Model struct {
|
|||||||
activePost *post.Post
|
activePost *post.Post
|
||||||
allReplies []*reply.Reply
|
allReplies []*reply.Reply
|
||||||
activeReply *reply.Reply
|
activeReply *reply.Reply
|
||||||
|
|
||||||
|
viewcache string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Model) Init() tea.Cmd {
|
func (m Model) Init() tea.Cmd {
|
||||||
@ -78,6 +80,8 @@ func NewModel(c *ctx.Ctx) Model {
|
|||||||
|
|
||||||
buffer: "",
|
buffer: "",
|
||||||
replyIDs: []string{},
|
replyIDs: []string{},
|
||||||
|
|
||||||
|
viewcache: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
m.a, _ = aggregator.New(m.ctx)
|
m.a, _ = aggregator.New(m.ctx)
|
||||||
@ -103,6 +107,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
// // TODO: Handle error
|
// // TODO: Handle error
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
m.viewcache = m.buildView(false)
|
||||||
|
|
||||||
cmd := cmd.New(cmd.WinOpen, postcreate.WIN_ID, cmd.Arg{
|
cmd := cmd.New(cmd.WinOpen, postcreate.WIN_ID, cmd.Arg{
|
||||||
Name: "post",
|
Name: "post",
|
||||||
Value: &m.activePost,
|
Value: &m.activePost,
|
||||||
@ -218,6 +224,12 @@ func (m Model) View() string {
|
|||||||
func (m Model) buildView(cached bool) string {
|
func (m Model) buildView(cached bool) string {
|
||||||
var view strings.Builder = strings.Builder{}
|
var view strings.Builder = strings.Builder{}
|
||||||
|
|
||||||
|
if cached && m.focused == false && m.viewcache != "" {
|
||||||
|
m.ctx.Logger.Debugln("Cached View()")
|
||||||
|
|
||||||
|
return m.viewcache
|
||||||
|
}
|
||||||
|
|
||||||
var style lipgloss.Style
|
var style lipgloss.Style
|
||||||
if m.focused {
|
if m.focused {
|
||||||
style = m.ctx.Theme.DialogBox.Titlebar.Focused
|
style = m.ctx.Theme.DialogBox.Titlebar.Focused
|
||||||
|
Loading…
Reference in New Issue
Block a user