From 035344054768562bee7db12e02e3bec1c8409210 Mon Sep 17 00:00:00 2001 From: citrons Date: Mon, 2 Jun 2025 17:38:27 -0500 Subject: window history --- client/application.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'client/application.go') diff --git a/client/application.go b/client/application.go index fb12717..35f38c8 100644 --- a/client/application.go +++ b/client/application.go @@ -17,6 +17,7 @@ type application struct { cache object.ObjCache windowCache window.WindowCache currentWindow window.Location + windowHist []window.Location cmdWindow cmdWindow prompts []window.Prompt } @@ -24,7 +25,7 @@ type application struct { func newApplication(serverAddress string) *application { var app application app.Client = client.New(serverAddress) - app.currentWindow = app.cmdWindow.Location() + app.goTo(app.cmdWindow.Location()) app.cache = object.NewCache(&app) app.windowCache = window.NewCache() @@ -68,6 +69,11 @@ func (a *application) OnEvent(cmd proto.Command) { } case "delete": a.cache.Gone(cmd.Target) + cl := channelLocation {cmd.Target} + if a.windowCache.Get(cl) != nil { + a.windowCache.Evict(cl) + a.removeFromHistory(cl) + } } } @@ -164,7 +170,7 @@ func (a *application) join(channelName string) { a.Request(proto.NewCmd("join", ch.Id), func(response proto.Command) { switch response.Kind { case "ok": - a.currentWindow = channelLocation {id: ch.Id} + a.goTo(channelLocation {id: ch.Id}) case "fail": if len(response.Args) > 0 { f := proto.Fail(response.Args[0]) @@ -182,7 +188,7 @@ func (a *application) createChannel(name string) { case "create": if len(response.Args) > 0 { ch := response.Args[0] - a.currentWindow = channelLocation {id: ch.Id} + a.goTo(channelLocation {id: ch.Id}) } case "fail": if len(response.Args) > 0 { -- cgit v1.2.3