okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
60af226
main
1package tui 2 3import ( 4"albedo/cli/internal/daemon" 5"slices" 6) 7 8func (m * AppModel )session (id string ) (daemon.Session ,bool ) { 9if m .ActiveSession != nil && m .ActiveSession .ID == id { 10return * m .ActiveSession ,true 11 } 12if i := slices .IndexFunc (m .Sessions ,func (s daemon.Session )bool {return s .ID == id });i >= 0 { 13return m .Sessions [i ],true 14 } 15return daemon.Session {},false 16} 17 18func (m * AppModel )updateSession (session daemon.Session ) { 19if i := slices .IndexFunc (m .Sessions ,func (s daemon.Session )bool {return s .ID == session .ID });i >= 0 { 20m .Sessions [i ]= session 21 } 22if m .ActiveSession != nil && m .ActiveSession .ID == session .ID { 23captured := session 24m .ActiveSession = & captured 25 } 26m .updateSessionPickerItems () 27} 28 29func (m * AppModel )applySessionList (sessions []daemon.Session ) { 30m .Sessions = slices .Clone (sessions ) 31if m .ActiveSession != nil { 32if i := slices .IndexFunc (sessions ,func (s daemon.Session )bool {return s .ID == m .ActiveSession .ID });i >= 0 { 33// Listings omit details available from a session snapshot. 34captured := * m .ActiveSession 35listed := sessions [i ] 36captured .Title ,captured .Pinned ,captured .Archived ,captured .Opens = listed .Title ,listed .Pinned ,listed .Archived ,listed .Opens 37if listed .ETag != "" { 38captured .ETag = listed .ETag 39 } 40m .ActiveSession = & captured 41 } 42 } 43m .updateSessionPickerItems () 44}