修复列表数据重复

This commit is contained in:
wh_zcy 2022-10-09 18:14:43 +08:00
parent 485021f72f
commit d3ae4591aa
8 changed files with 43 additions and 22 deletions

View File

@ -4,5 +4,5 @@ Website = "http://legu.cc"
Icon = "app.png"
Name = "RobotGUI"
ID = "cc.legu.app"
Version = "1.0.13"
Build = 16
Version = "1.0.14"
Build = 17

View File

@ -56,6 +56,10 @@ func (f *ItemList) CreateList() *widget.List {
f.SelItemIds = append(f.SelItemIds, selId)
return
}
f.ItemList.OnUnselected = func(id widget.ListItemID) {
f.SelItemIds = append(f.SelItemIds[:id], f.SelItemIds[id+1:]...)
}
return f.ItemList
}

View File

@ -5,7 +5,6 @@ import (
"go_dreamfactory/cmd/v2/lib/common"
"go_dreamfactory/cmd/v2/model"
"go_dreamfactory/cmd/v2/service/observer"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
@ -74,7 +73,6 @@ func (a appMonitor) OnClose() bool {
func (this *appMonitor) Run() {
this.obs.AddListener(observer.EVENT_APP_MONI, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
time.Sleep(time.Millisecond * 20)
data := d.(*model.PushModel)
this.monitorData.DataList = append(this.monitorData.DataList, data)
this.reloadMonitorData()
@ -88,7 +86,6 @@ func (this *appMonitor) reloadMonitorData() {
d := this.monitorData.AsInterfaceArray()
this.monitorBinding.Set(d)
}
this.monitorList.ScrollToBottom()
}
func (this *appMonitor) createMonitorList() {

View File

@ -19,6 +19,7 @@ import (
type FriendListView struct {
ListBaseView //继承支持好友列表的基类
friendList func()
flag bool
}
func (this *FriendListView) CreateView(t *model.TestCase) fyne.CanvasObject {
@ -70,6 +71,9 @@ func (this *FriendListView) Load() {
}
func (this *FriendListView) dataListener() {
if this.flag {
return
}
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage)
@ -95,4 +99,5 @@ func (this *FriendListView) dataListener() {
this.reloadListData()
},
})
this.flag = true
}

View File

@ -21,6 +21,7 @@ type HeroListView struct {
ListBaseView
subWindows *SubWindowListView
heroList []*pb.DBHero
flag bool
}
func (this *HeroListView) CreateView(t *model.TestCase) fyne.CanvasObject {
@ -107,6 +108,9 @@ func (this *HeroListView) CreateView(t *model.TestCase) fyne.CanvasObject {
}
func (this *HeroListView) dataListener() {
if this.flag {
return
}
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage)
@ -135,4 +139,5 @@ func (this *HeroListView) dataListener() {
this.reloadListData()
},
})
this.flag = true
}

View File

@ -20,6 +20,7 @@ import (
type RtaskListView struct {
ListBaseView
flag bool
}
func (this *RtaskListView) CreateView(t *model.TestCase) fyne.CanvasObject {
@ -77,6 +78,9 @@ func (this *RtaskListView) CreateView(t *model.TestCase) fyne.CanvasObject {
}
func (this *RtaskListView) dataListener() {
if this.flag {
return
}
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage)
@ -101,4 +105,5 @@ func (this *RtaskListView) dataListener() {
this.reloadListData()
},
})
this.flag = true
}

View File

@ -21,16 +21,16 @@ import (
)
type TaskActiveListView struct {
ListBaseView
BaseformView
activeVal *widget.Label
itemList *common.ItemList
flag bool
}
func (this *TaskActiveListView) CreateView(t *model.TestCase) fyne.CanvasObject {
// init required
this.initItemList()
this.itemList = common.NewItemList()
// create friend list view
this.createItemList()
this.itemList.ItemList = this.itemList.CreateList()
// select widget
tagSelect := getTaskTagSelect()
@ -50,20 +50,20 @@ func (this *TaskActiveListView) CreateView(t *model.TestCase) fyne.CanvasObject
//receive button
receiveBtn := widget.NewButtonWithIcon("领取", theme.ConfirmIcon(), func() {
if len(this.selItemIds) != 1 {
if len(this.itemList.SelItemIds) != 1 {
dialog.ShowError(errors.New("请选择一项"), this.w)
return
}
if err := service.GetPttService().SendToClient(
t.MainType, "activereceive",
&pb.TaskActiveReceiveReq{Id: this.selItemIds[0], TaskTag: cast.ToInt32(tagSelect.Selected)}); err != nil {
&pb.TaskActiveReceiveReq{Id: this.itemList.SelItemIds[0], TaskTag: cast.ToInt32(tagSelect.Selected)}); err != nil {
logrus.Error(err)
return
}
})
// layout
split := container.NewHSplit(this.dataListWidget, container.NewVBox(this.activeVal, this.form, taskListBtn, receiveBtn))
split := container.NewHSplit(this.itemList.ItemList, container.NewVBox(this.activeVal, this.form, taskListBtn, receiveBtn))
split.Offset = 1
//data listener for
@ -73,6 +73,9 @@ func (this *TaskActiveListView) CreateView(t *model.TestCase) fyne.CanvasObject
}
func (this *TaskActiveListView) dataListener() {
if this.flag {
return
}
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage)
@ -88,16 +91,15 @@ func (this *TaskActiveListView) dataListener() {
this.activeVal.SetText(fmt.Sprintf("当前活跃度:%v", rsp.Active))
this.itemListData = model.NewItemModelList()
for _, v := range rsp.List {
fm := &model.ItemModel{
Id: cast.ToString(v.Id),
Label: fmt.Sprintf("%s R:%d", cast.ToString(v.RId), v.Received),
item := common.Item{
Id: cast.ToString(v.Id),
Text: fmt.Sprintf("%s R:%d", cast.ToString(v.RId), v.Received),
}
this.itemListData.DataList = append(this.itemListData.DataList, fm)
this.itemList.AddItem(item)
}
this.reloadListData()
},
})
this.flag = true
}

View File

@ -23,6 +23,7 @@ import (
type TaskListView struct {
BaseformView
itemList common.ItemList
flag bool
}
func (this *TaskListView) CreateView(t *model.TestCase) fyne.CanvasObject {
@ -68,6 +69,9 @@ func (this *TaskListView) CreateView(t *model.TestCase) fyne.CanvasObject {
}
func (this *TaskListView) dataListener() {
if this.flag {
return
}
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage)
@ -82,8 +86,6 @@ func (this *TaskListView) dataListener() {
return
}
this.itemList.Reset()
for _, v := range rsp.List {
item := common.Item{
Id: cast.ToString(v.Id),
@ -93,4 +95,5 @@ func (this *TaskListView) dataListener() {
}
},
})
this.flag = true
}