Skip to content

Commit

Permalink
some edits
Browse files Browse the repository at this point in the history
  • Loading branch information
ZORbit01 committed Apr 11, 2023
1 parent 13ee04e commit 5f4ef02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 10 additions & 2 deletions client/leaderView.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
}()

}
}
}
8 changes: 4 additions & 4 deletions client/soldierView.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5f4ef02

Please sign in to comment.