1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-09-15 04:28:07 -04:00

Fixed view caching

This commit is contained in:
マリウス 2023-01-01 21:22:16 -05:00
parent 8bd83d75c1
commit cfd01d90d2
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F

View File

@ -130,7 +130,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} else if m.focused == "post" {
m.focused = "reply"
m.viewcache = m.View()
m.ctx.Logger.Debugln("caching view")
m.ctx.Logger.Debugf("buffer: %s", m.buffer)
m.viewcache = m.buildView(false)
return m, m.textarea.Focus()
}
@ -216,9 +218,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (m Model) View() string {
return m.buildView(true)
}
func (m Model) buildView(cached bool) string {
var view strings.Builder = strings.Builder{}
if m.focused == "reply" && m.viewcache != "" {
if cached && m.focused == "reply" && m.viewcache != "" {
m.ctx.Logger.Debugln("Cached View()")
m.textarea.SetWidth(m.viewcacheTextareaXY[2])