Skip to content

Commit 7d38fa4

Browse files
authored
Team member page: final touchups (keybase#23186)
1 parent 5b71aa1 commit 7d38fa4

26 files changed

Lines changed: 668 additions & 255 deletions

File tree

‎go/chat/server.go‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030
"github.com/keybase/client/go/teams/opensearch"
3131
"github.com/keybase/pipeliner"
3232
"golang.org/x/net/context"
33+
"golang.org/x/sync/errgroup"
34+
"golang.org/x/sync/semaphore"
3335
)
3436

3537
type UISource interface {
@@ -3643,7 +3645,47 @@ func (h *Server) GetLastActiveAtLocal(ctx context.Context, arg chat1.GetLastActi
36433645
if err != nil {
36443646
return 0, err
36453647
}
3646-
return h.G().TeamChannelSource.GetLastActiveAt(ctx, arg.TeamID, arg.Uid, h.remoteClient())
3648+
uid := gregor1.UID(libkb.UsernameToUID(arg.Username).ToBytes())
3649+
return h.G().TeamChannelSource.GetLastActiveAt(ctx, arg.TeamID, uid, h.remoteClient())
3650+
}
3651+
3652+
func (h *Server) GetLastActiveAtMultiLocal(ctx context.Context, arg chat1.GetLastActiveAtMultiLocalArg) (res map[keybase1.TeamID]gregor1.Time, err error) {
3653+
ctx = globals.ChatCtx(ctx, h.G(), keybase1.TLFIdentifyBehavior_CHAT_GUI, nil, h.identNotifier)
3654+
defer h.Trace(ctx, func() error { return err }, "GetLastActiveAtMultiLocal")()
3655+
_, err = utils.AssertLoggedInUID(ctx, h.G())
3656+
if err != nil {
3657+
return nil, err
3658+
}
3659+
uid := gregor1.UID(libkb.UsernameToUID(arg.Username).ToBytes())
3660+
3661+
res = map[keybase1.TeamID]gregor1.Time{}
3662+
resMu := sync.Mutex{}
3663+
sem := semaphore.NewWeighted(10)
3664+
eg, subctx := errgroup.WithContext(ctx)
3665+
for _, teamID := range arg.TeamIDs {
3666+
if err := sem.Acquire(subctx, 1); err != nil {
3667+
return nil, err
3668+
}
3669+
3670+
teamID := teamID
3671+
eg.Go(func() error {
3672+
defer sem.Release(1)
3673+
3674+
lastActive, err := h.G().TeamChannelSource.GetLastActiveAt(subctx, teamID, uid, h.remoteClient())
3675+
if err != nil {
3676+
return err
3677+
}
3678+
resMu.Lock()
3679+
res[teamID] = lastActive
3680+
resMu.Unlock()
3681+
return nil
3682+
})
3683+
}
3684+
if err := eg.Wait(); err != nil {
3685+
return nil, err
3686+
}
3687+
3688+
return res, nil
36473689
}
36483690

36493691
func (h *Server) AddEmoji(ctx context.Context, arg chat1.AddEmojiArg) (res chat1.AddEmojiRes, err error) {

‎go/chat/server_test.go‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8288,26 +8288,26 @@ func TestChatSrvGetLastActiveAt(t *testing.T) {
82888288
defer ctc.cleanup()
82898289
users := ctc.users()
82908290

8291-
uid1 := gregor1.UID(users[0].User.GetUID().ToBytes())
8292-
uid2 := gregor1.UID(users[1].User.GetUID().ToBytes())
8291+
username1 := users[0].User.GetName()
8292+
username2 := users[1].User.GetName()
82938293
tc := ctc.as(t, users[0])
82948294
created := mustCreateConversationForTest(t, ctc, users[0], chat1.TopicType_CHAT, mt, users[1])
82958295
mustPostLocalForTest(t, ctc, users[0], created, chat1.NewMessageBodyWithText(chat1.MessageText{
82968296
Body: "HI",
82978297
}))
82988298

82998299
teamID := keybase1.TeamID(created.Triple.Tlfid.String())
8300-
t.Logf("teamID: %v, uid1: %v, uid2: %v", teamID, users[0].User.GetUID(), users[1].User.GetUID())
8300+
t.Logf("teamID: %v, username1: %v, username2: %v", teamID, username1, username2)
83018301
lastActiveAt, err := tc.chatLocalHandler().GetLastActiveAtLocal(context.TODO(), chat1.GetLastActiveAtLocalArg{
8302-
TeamID: teamID,
8303-
Uid: uid1,
8302+
TeamID: teamID,
8303+
Username: username1,
83048304
})
83058305
require.NoError(t, err)
83068306
require.NotZero(t, lastActiveAt)
83078307

83088308
lastActiveAt, err = tc.chatLocalHandler().GetLastActiveAtLocal(context.TODO(), chat1.GetLastActiveAtLocalArg{
8309-
TeamID: teamID,
8310-
Uid: uid2,
8309+
TeamID: teamID,
8310+
Username: username2,
83118311
})
83128312
require.NoError(t, err)
83138313
require.Zero(t, lastActiveAt)
@@ -8316,17 +8316,17 @@ func TestChatSrvGetLastActiveAt(t *testing.T) {
83168316
Body: "HI",
83178317
}))
83188318
lastActiveAt, err = tc.chatLocalHandler().GetLastActiveAtLocal(context.TODO(), chat1.GetLastActiveAtLocalArg{
8319-
TeamID: teamID,
8320-
Uid: uid2,
8319+
TeamID: teamID,
8320+
Username: username2,
83218321
})
83228322
require.NoError(t, err)
83238323
require.Zero(t, lastActiveAt)
83248324

83258325
err = tc.h.G().TeamChannelSource.OnDbNuke(tc.m)
83268326
require.NoError(t, err)
83278327
lastActiveAt, err = tc.chatLocalHandler().GetLastActiveAtLocal(context.TODO(), chat1.GetLastActiveAtLocalArg{
8328-
TeamID: teamID,
8329-
Uid: uid2,
8328+
TeamID: teamID,
8329+
Username: username2,
83308330
})
83318331
require.NoError(t, err)
83328332
require.NotZero(t, lastActiveAt)

‎go/protocol/chat1/local.go‎

Lines changed: 28 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎protocol/avdl/chat1/local.avdl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,8 @@ protocol local {
13681368
// queue up a refresh of participants, this will result in notifications to the UI with the data
13691369
// from local and remote sources
13701370
void refreshParticipants(ConversationID convID);
1371-
gregor1.Time getLastActiveAtLocal(keybase1.TeamID teamID, gregor1.UID uid);
1371+
gregor1.Time getLastActiveAtLocal(keybase1.TeamID teamID, string username);
1372+
map<keybase1.TeamID, gregor1.Time> getLastActiveAtMultiLocal(array<keybase1.TeamID> teamIDs, string username);
13721373

13731374
// Emoji
13741375
record AddEmojiRes {

‎protocol/bin/enabled-calls.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"chat.1.local.cancelActiveInboxSearch": {"promise": true},
1313
"chat.1.local.cancelActiveSearch": {"promise": true},
1414
"chat.1.local.cancelUploadTempFile": {"promise": true},
15-
"chat.1.local.cancelUploadTempFile": {"promise": true},
1615
"chat.1.local.deleteConversationLocal": {"promise": true},
1716
"chat.1.local.dismissJourneycard": {"promise": true},
1817
"chat.1.local.editBotMember": {"promise": true},
@@ -23,6 +22,7 @@
2322
"chat.1.local.getGlobalAppNotificationSettingsLocal": {"promise": true},
2423
"chat.1.local.getInboxAndUnboxUILocal": {"promise": true},
2524
"chat.1.local.getInboxNonblockLocal": {"engineSaga": true},
25+
"chat.1.local.getLastActiveAtMultiLocal": {"promise": true},
2626
"chat.1.local.getMutualTeamsLocal": {"promise": true},
2727
"chat.1.local.getNextAttachmentMessageLocal": {"promise": true},
2828
"chat.1.local.getStaticConfig": {"promise": true},

‎protocol/json/chat1/local.json‎

Lines changed: 22 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎shared/actions/json/teams.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,17 @@
392392
"initialTab?": "Types.TabKey",
393393
"addMembers?": "boolean"
394394
},
395+
"setMemberActivityDetails": {
396+
"activityMap": "Map<Types.TeamID, number>",
397+
"username": "string"
398+
},
395399
"getMemberSubteamDetails": {
396400
"teamID": "Types.TeamID",
397401
"username": "string"
398402
},
399403
"setMemberSubteamDetails": {
400404
"username": "string",
401-
"memberships": "Map<Types.TeamID, Types.MemberInfo>"
405+
"memberships": "Map<Types.TeamID, Types.MemberInfoWithLastActivity>"
402406
},
403407
"startNewTeamWizard": {},
404408
"setTeamWizardTeamType": {

‎shared/actions/teams-gen.tsx‎

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)