修复了聊天数据异常丢失的bug

This commit is contained in:
2024-10-18 18:15:44 +08:00
parent b27d2b80f7
commit 8a8a6e0bfa
6 changed files with 40 additions and 24 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ func OpenChat(user models.Users) {
return
}
my := repo.User.GetUserInfo(global.DB)
chatItem := models.NewTextChatMsg(my, en.Text)
chatItem := models.NewTextChatMsg(my, user.ID, en.Text)
userInfo.messages = append(userInfo.messages, *chatItem)
_ = repo.ChatMsg.Create(global.DB, chatItem)
list.Add(itemMessage(*chatItem))
+5 -2
View File
@@ -53,7 +53,10 @@ func StartGameListen() {
case "/close_game":
g := global.GetGameInfo(msg.GameUuid)
if g != nil {
dialog.ShowInformation("提示", "对方已退出", g.Obj.(*TenGame).w)
dialog.NewConfirm("提示", "对方已退出", func(b bool) {
g.Obj.(*TenGame).w.Close()
}, g.Obj.(*TenGame).w).Show()
//dialog.ShowInformation("提示", "对方已退出", g.Obj.(*TenGame).w)
}
case "/start_game":
g := global.GetGameInfo(msg.GameUuid)
@@ -244,7 +247,7 @@ func (t *TenGame) advance() {
}
func (t *TenGame) setTitle() {
title := fmt.Sprintf("Game %0.f*%0.f win:%d", t.itemX, t.itemY, t.winSum)
title := fmt.Sprintf("让我们来下棋 %0.f*%0.f win:%d", t.itemX, t.itemY, t.winSum)
if t.isNet {
title += fmt.Sprintf(" | 我 vs %s", t.user.Name)
if t.currentRoundPlayer == t.myIndex {
+12 -6
View File
@@ -1,6 +1,7 @@
package views
import (
"fmt"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
@@ -44,12 +45,17 @@ func baseCardView(
baseCardV = widget.NewCard(baseCardCopy.Title, baseCardCopy.Text, container.NewBorder(nil, widget.NewToolbar(
widget.NewToolbarAction(theme.ContentAddIcon(), func() {}),
widget.NewToolbarAction(theme.DeleteIcon(), func() {
err := service.BaseCard.Delete(global.DB, baseCardCopy)
if err != nil {
dialog.ShowInformation("删除失败", err.Error(), w)
return
}
gridWrap.Remove(baseCardV)
dialog.NewConfirm("提示", fmt.Sprintf("确定删除:%s?", baseCardCopy.Title), func(b bool) {
if b {
err := service.BaseCard.Delete(global.DB, baseCardCopy)
if err != nil {
dialog.ShowInformation("删除失败", err.Error(), w)
return
}
gridWrap.Remove(baseCardV)
}
}, w).Show()
}),
widget.NewToolbarAction(theme.SettingsIcon(), func() {
info := cardTypeMap[baseCardCopy.ToolType]