diff options
Diffstat (limited to 'helpers.go')
| -rw-r--r-- | helpers.go | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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) +} |
