1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-12-04 14:46:37 -05:00

Enabled viewcache for postshow

This commit is contained in:
マリウス 2023-01-02 18:53:28 -05:00
parent d9c07422d6
commit 02a88f4ee9
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F

View File

@ -56,6 +56,8 @@ type Model struct {
activePost *post.Post
allReplies []*reply.Reply
activeReply *reply.Reply
viewcache string
}
func (m Model) Init() tea.Cmd {
@ -78,6 +80,8 @@ func NewModel(c *ctx.Ctx) Model {
buffer: "",
replyIDs: []string{},
viewcache: "",
}
m.a, _ = aggregator.New(m.ctx)
@ -103,6 +107,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// // TODO: Handle error
// }
// }
m.viewcache = m.buildView(false)
cmd := cmd.New(cmd.WinOpen, postcreate.WIN_ID, cmd.Arg{
Name: "post",
Value: &m.activePost,
@ -218,6 +224,12 @@ func (m Model) View() string {
func (m Model) buildView(cached bool) string {
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
if m.focused {
style = m.ctx.Theme.DialogBox.Titlebar.Focused