修复跨服用户搜索

This commit is contained in:
wh_zcy 2022-10-19 19:22:22 +08:00
parent 835f88650b
commit 5bbaada9e2
5 changed files with 63 additions and 29 deletions

View File

@ -4,5 +4,5 @@ Website = "http://legu.cc"
Icon = "app.png"
Name = "RobotGUI"
ID = "cc.legu.app"
Version = "1.0.15"
Build = 18
Version = "1.0.16"
Build = 19

View File

@ -174,7 +174,7 @@ var (
ff(comm.ModuleFriend, friend.FriendSubTypeBlacklist),
ff(comm.ModuleFriend, friend.FriendSubTypeAddBlack),
ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack),
ff(comm.ModuleFriend, friend.FriendSubTypeSearch),
// ff(comm.ModuleFriend, friend.FriendSubTypeSearch),
// ff(comm.ModuleFriend, friend.FriendSubTypeZanList),
ff(comm.ModuleFriend, friend.FriendSubTypeRandList),
ff(comm.ModuleFriend, friend.FriendSubTypeGetreward),
@ -586,15 +586,15 @@ var (
Rsp: &pb.FriendAgreeResp{},
Enabled: true,
},
ff(comm.ModuleFriend, friend.FriendSubTypeSearch): {
NavLabel: "好友搜索",
Desc: "搜索好友",
MainType: string(comm.ModuleFriend),
SubType: friend.FriendSubTypeSearch,
Req: &pb.FriendSearchReq{},
Rsp: &pb.FriendSearchResp{},
Enabled: true,
},
// ff(comm.ModuleFriend, friend.FriendSubTypeSearch): {
// NavLabel: "好友搜索",
// Desc: "搜索好友",
// MainType: string(comm.ModuleFriend),
// SubType: friend.FriendSubTypeSearch,
// Req: &pb.FriendSearchReq{},
// Rsp: &pb.FriendSearchResp{},
// Enabled: true,
// },
ff(comm.ModuleFriend, friend.FriendSubTypeAssistHero): {
NavLabel: "助战英雄",
Desc: "助战英雄",

View File

@ -11,14 +11,16 @@ import (
type FriendAssistListView struct {
BaseformView
friendAssistList func()
}
func (this *FriendAssistListView) CreateView(t *model.TestCase) fyne.CanvasObject {
this.form.OnSubmit = func() {
this.friendAssistList = func() {
if err := service.GetPttService().SendToClient(t.MainType, t.SubType,
&pb.FriendAssistlistReq{}); err != nil {
logrus.Error(err)
}
}
defer this.friendAssistList()
return this.form
}

View File

@ -56,7 +56,25 @@ func (this *FriendRandListView) CreateView(t *model.TestCase) fyne.CanvasObject
}
})
btnBar := container.NewHBox(refreshBtn, friendApplyBtn)
nicknameEntry := widget.NewEntry()
nicknameEntry.PlaceHolder = "搜索昵称"
searchBtn := widget.NewButtonWithIcon("", theme.SearchIcon(), func() {
if nicknameEntry.Text == "" {
common.ShowTip("请输入昵称")
return
}
this.itemList.Reset()
if err := service.GetPttService().SendToClient(
t.MainType,
friend.FriendSubTypeSearch,
&pb.FriendSearchReq{NickName: nicknameEntry.Text},
); err != nil {
logrus.Error(err)
return
}
})
btnBar := container.NewBorder(nil, nil, container.NewHBox(refreshBtn, friendApplyBtn), searchBtn, nicknameEntry)
// layout
c := container.NewBorder(btnBar, nil, nil, nil, this.itemList.ItemList)
@ -72,23 +90,33 @@ func (this *FriendRandListView) dataListener() {
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage)
if !(data.MainType == string(comm.ModuleFriend) &&
data.SubType == friend.FriendSubTypeRandList) {
return
}
rsp := &pb.FriendRandlistResp{}
if !comm.ProtoUnmarshal(data, rsp) {
logrus.Error("unmarshal err")
return
}
for _, v := range rsp.List {
item := common.Item{
Id: v.UserId,
Text: fmt.Sprintf("%s 服务:%s", v.NickName, v.ServerId),
if data.MainType == string(comm.ModuleFriend) && data.SubType == friend.FriendSubTypeRandList {
rsp := &pb.FriendRandlistResp{}
if !comm.ProtoUnmarshal(data, rsp) {
logrus.Error("unmarshal err")
return
}
for i, v := range rsp.List {
item := common.Item{
Id: v.UserId,
Text: fmt.Sprintf("%d 昵称:%s 服务:%s", i+1, v.NickName, v.ServerId),
}
this.itemList.AddItem(item)
}
} else if data.MainType == string(comm.ModuleFriend) && data.SubType == friend.FriendSubTypeSearch {
rsp := &pb.FriendSearchResp{}
if !comm.ProtoUnmarshal(data, rsp) {
logrus.Error("unmarshal err")
return
}
for i, v := range rsp.Friends {
item := common.Item{
Id: v.UserId,
Text: fmt.Sprintf("%d 昵称:%s 服务:%s", i+1, v.NickName, v.ServerId),
}
this.itemList.AddItem(item)
}
this.itemList.AddItem(item)
}
},

View File

@ -30,6 +30,10 @@ func (this *apiComp) Search(session comm.IUserSession, req *pb.FriendSearchReq)
}
for _, u := range users {
// 排除自己
if u.Uid == session.GetUserId() {
continue
}
resp.Friends = append(resp.Friends, &pb.FriendBase{
UserId: u.Uid,
NickName: u.Name,