From 5f4ef02212b5e2ee6c09b5ff8cf11b0ea9304a85 Mon Sep 17 00:00:00 2001 From: ali Date: Wed, 12 Apr 2023 02:23:32 +0300 Subject: [PATCH] some edits --- client/leaderView.go | 12 ++++++++++-- client/soldierView.go | 8 ++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/client/leaderView.go b/client/leaderView.go index 19def75..2ed2dae 100644 --- a/client/leaderView.go +++ b/client/leaderView.go @@ -165,7 +165,10 @@ func (v *leaderView) updateDataForLeader(data CampAPI) { v.Soldiers.Rows = append(v.Soldiers.Rows, []string{"", "", ""}) } } -func (l *Leader) StartLeaderView(changedDataChan chan CampAPI) { +func (v *leaderView) addLog(log string) { + v.Logs.Rows = append(v.Logs.Rows, log) +} +func (l *Leader) StartLeaderView(changedDataChan chan CampAPI, logChan chan string) { v := newLeaderView() v.Init() defer ui.Close() @@ -244,7 +247,12 @@ func (l *Leader) StartLeaderView(changedDataChan chan CampAPI) { v.updateDataForLeader(data) v.Render() }() - default: + case log := <-logChan: + go func() { + v.addLog(log) + v.Render() + }() + } } } diff --git a/client/soldierView.go b/client/soldierView.go index fb1b30f..607d75c 100644 --- a/client/soldierView.go +++ b/client/soldierView.go @@ -136,10 +136,10 @@ func (v *soldierView) updateDataForSoldier(data CampAPI) { } } -func (v *soldierView) AddLog(log string) { +func (v *soldierView) addLog(log string) { v.Logs.Rows = append(v.Logs.Rows, log) } -func StartSoldierView(changedDataChan chan CampAPI) { +func StartSoldierView(changedDataChan chan CampAPI, logChan chan string) { v := newSoldierView() v.Init() defer ui.Close() @@ -167,9 +167,9 @@ func StartSoldierView(changedDataChan chan CampAPI) { v.updateDataForSoldier(data) v.Render() }() - case log := <-LogChan: + case log := <-logChan: go func() { - v.AddLog(log) + v.addLog(log) v.Render() }() default: