summaryrefslogtreecommitdiff
path: root/helpers.go
diff options
context:
space:
mode:
Diffstat (limited to 'helpers.go')
-rw-r--r--helpers.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/helpers.go b/helpers.go
index 7841e87..5b42533 100644
--- a/helpers.go
+++ b/helpers.go
@@ -19,7 +19,7 @@ func (c *Chats) AddGeminiComment(s string) *Chat {
chat.Content = s
chat.Ctime = timestamppb.New(time.Now())
- c.Append(chat)
+ c.AppendNew(chat)
return chat
}
@@ -30,7 +30,7 @@ func (c *Chats) AddUserComment(s string) *Chat {
chat.From = Who_USER
chat.Content = s
- c.Append(chat)
+ c.AppendNew(chat)
return chat
}
@@ -83,7 +83,7 @@ func (all *Chats) AddFile(filename string) error {
}
newc.Content = content
newc.VerifyUuid()
- all.AppendByUuid(newc)
+ all.AppendNew(newc)
}
return nil
@@ -110,3 +110,13 @@ func (c *Chat) VerifyUuid() bool {
}
return false
}
+
+func (x *Chats) AppendNew(y *Chat) {
+ x.Lock()
+ defer x.Unlock()
+
+ var chat *Chat
+ chat = proto.Clone(y).(*Chat)
+
+ x.Chats = append(x.Chats, chat)
+}