Skip to content

Commit a04a8a6

Browse files
authored
have JS trigger meta reload on expunge (keybase#18931)
1 parent e906c0c commit a04a8a6

12 files changed

Lines changed: 28 additions & 154 deletions

File tree

‎go/chat/botcommands_test.go‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,9 @@ func TestBotCommandManager(t *testing.T) {
8484
}
8585
}
8686
select {
87-
case items := <-listener0.convsUpdated:
87+
case items := <-listener0.threadsStale:
8888
require.Equal(t, 1, len(items))
89-
require.Equal(t, impConv.Id.String(), items[0].ConvID)
90-
typ, err := items[0].BotCommands.Typ()
91-
require.NoError(t, err)
92-
require.Equal(t, chat1.ConversationCommandGroupsTyp_CUSTOM, typ)
89+
require.Equal(t, impConv.Id, items[0].ConvID)
9390
case <-time.After(timeout):
9491
require.Fail(t, "no stale")
9592
}

‎go/chat/bots/commands.go‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
"github.com/keybase/client/go/chat/globals"
1818
"github.com/keybase/client/go/chat/storage"
19-
"github.com/keybase/client/go/chat/types"
2019
"github.com/keybase/client/go/chat/utils"
2120
"github.com/keybase/client/go/libkb"
2221
"github.com/keybase/client/go/protocol/chat1"
@@ -415,19 +414,12 @@ func (b *CachingBotCommandManager) commandUpdate(ctx context.Context, job comman
415414
if err := storage.NewInbox(b.G()).IncrementLocalConvVersion(ctx, b.uid, job.convID); err != nil {
416415
b.Debug(ctx, "commandUpdate: unable to IncrementLocalConvVersion, err", err)
417416
}
418-
conv, err := utils.GetVerifiedConv(ctx, b.G(), b.uid, job.convID, types.InboxSourceDataSourceAll)
419-
if err != nil {
420-
return err
421-
}
422-
username, err := b.getMyUsername(ctx)
423-
if err != nil {
424-
return err
425-
}
426-
act := chat1.NewChatActivityWithConvsUpdated(chat1.ConvsUpdated{
427-
Items: []chat1.InboxUIItem{utils.PresentConversationLocal(ctx, conv, username)},
417+
b.G().ActivityNotifier.ThreadsStale(ctx, b.uid, []chat1.ConversationStaleUpdate{
418+
{
419+
ConvID: job.convID,
420+
UpdateType: chat1.StaleUpdateType_CONVUPDATE,
421+
},
428422
})
429-
b.G().ActivityNotifier.Activity(ctx, b.uid, chat1.TopicType_CHAT, &act,
430-
chat1.ChatActivitySource_LOCAL)
431423
return nil
432424
}
433425

‎go/chat/convsource.go‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -866,21 +866,29 @@ func (s *HybridConversationSource) GetUnreadline(ctx context.Context,
866866
func (s *HybridConversationSource) notifyExpunge(ctx context.Context, uid gregor1.UID,
867867
convID chat1.ConversationID, mergeRes storage.MergeResult) {
868868
if mergeRes.Expunged != nil {
869-
var inboxItem *chat1.InboxUIItem
870869
topicType := chat1.TopicType_NONE
871870
conv, err := utils.GetVerifiedConv(ctx, s.G(), uid, convID, types.InboxSourceDataSourceAll)
872871
if err != nil {
873872
s.Debug(ctx, "notifyExpunge: failed to get conversations: %s", err)
874873
} else {
875-
inboxItem = PresentConversationLocalWithFetchRetry(ctx, s.G(), uid, conv)
876874
topicType = conv.GetTopicType()
877875
}
878876
act := chat1.NewChatActivityWithExpunge(chat1.ExpungeInfo{
879877
ConvID: convID,
880878
Expunge: *mergeRes.Expunged,
881-
Conv: inboxItem,
882879
})
883880
s.G().ActivityNotifier.Activity(ctx, uid, topicType, &act, chat1.ChatActivitySource_LOCAL)
881+
882+
// update inbox info as well
883+
if err := storage.NewInbox(s.G()).IncrementLocalConvVersion(ctx, uid, convID); err != nil {
884+
s.Debug(ctx, "notifyExpunge: unable to IncrementLocalConvVersion, err", err)
885+
}
886+
s.G().ActivityNotifier.ThreadsStale(ctx, uid, []chat1.ConversationStaleUpdate{
887+
{
888+
ConvID: convID,
889+
UpdateType: chat1.StaleUpdateType_CONVUPDATE,
890+
},
891+
})
884892
}
885893
}
886894

@@ -891,18 +899,18 @@ func (s *HybridConversationSource) notifyUpdated(ctx context.Context, uid gregor
891899
return
892900
}
893901
s.Debug(ctx, "notifyUpdated: notifying %d messages", len(msgs))
894-
conv, err := utils.GetUnverifiedConv(ctx, s.G(), uid, convID, types.InboxSourceDataSourceAll)
902+
conv, err := utils.GetVerifiedConv(ctx, s.G(), uid, convID, types.InboxSourceDataSourceAll)
895903
if err != nil {
896904
s.Debug(ctx, "notifyUpdated: failed to get conv: %s", err)
897905
return
898906
}
899-
updatedMsgs, err := s.TransformSupersedes(ctx, conv.Conv, uid, msgs, nil, nil, nil)
907+
updatedMsgs, err := s.TransformSupersedes(ctx, conv, uid, msgs, nil, nil, nil)
900908
if err != nil {
901909
s.Debug(ctx, "notifyUpdated: failed to transform supersedes: %s", err)
902910
return
903911
}
904912
s.Debug(ctx, "notifyUpdated: %d messages after transform", len(updatedMsgs))
905-
if updatedMsgs, err = NewReplyFiller(s.G()).Fill(ctx, uid, conv.Conv, updatedMsgs); err != nil {
913+
if updatedMsgs, err = NewReplyFiller(s.G()).Fill(ctx, uid, conv, updatedMsgs); err != nil {
906914
s.Debug(ctx, "notifyUpdated: failed to fill replies %s", err)
907915
return
908916
}
@@ -913,7 +921,7 @@ func (s *HybridConversationSource) notifyUpdated(ctx context.Context, uid gregor
913921
notif.Updates = append(notif.Updates, utils.PresentMessageUnboxed(ctx, s.G(), msg, uid, convID))
914922
}
915923
act := chat1.NewChatActivityWithMessagesUpdated(notif)
916-
s.G().ActivityNotifier.Activity(ctx, uid, chat1.TopicType_CHAT,
924+
s.G().ActivityNotifier.Activity(ctx, uid, conv.GetTopicType(),
917925
&act, chat1.ChatActivitySource_LOCAL)
918926
}
919927

‎go/chat/server_test.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,6 @@ type serverChatListener struct {
20172017
reactionUpdate chan chat1.ReactionUpdateNotif
20182018
messagesUpdated chan chat1.MessagesUpdated
20192019
readMessage chan chat1.ReadMessageInfo
2020-
convsUpdated chan []chat1.InboxUIItem
20212020

20222021
threadsStale chan []chat1.ConversationStaleUpdate
20232022
inboxStale chan struct{}
@@ -2086,8 +2085,6 @@ func (n *serverChatListener) NewChatActivity(uid keybase1.UID, activity chat1.Ch
20862085
n.messagesUpdated <- activity.MessagesUpdated()
20872086
case chat1.ChatActivityType_SET_STATUS:
20882087
n.setStatus <- activity.SetStatus()
2089-
case chat1.ChatActivityType_CONVS_UPDATED:
2090-
n.convsUpdated <- activity.ConvsUpdated().Items
20912088
}
20922089
}
20932090
func (n *serverChatListener) ChatJoinedConversation(uid keybase1.UID, convID chat1.ConversationID,
@@ -2149,7 +2146,6 @@ func newServerChatListener() *serverChatListener {
21492146
ephemeralPurge: make(chan chat1.EphemeralPurgeNotifInfo, buf),
21502147
reactionUpdate: make(chan chat1.ReactionUpdateNotif, buf),
21512148
messagesUpdated: make(chan chat1.MessagesUpdated, buf),
2152-
convsUpdated: make(chan []chat1.InboxUIItem, buf),
21532149

21542150
threadsStale: make(chan []chat1.ConversationStaleUpdate, buf),
21552151
inboxStale: make(chan struct{}, buf),

‎go/protocol/chat1/notify.go‎

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

‎protocol/avdl/chat1/notify.avdl‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ protocol NotifyChat {
2222
EXPUNGE_9,
2323
EPHEMERAL_PURGE_10,
2424
REACTION_UPDATE_11,
25-
MESSAGES_UPDATED_12,
26-
CONVS_UPDATED_13
25+
MESSAGES_UPDATED_12
2726
}
2827

2928
record IncomingMessage {
@@ -82,7 +81,6 @@ protocol NotifyChat {
8281
record ExpungeInfo {
8382
ConversationID convID;
8483
Expunge expunge;
85-
union { null, InboxUIItem } conv;
8684
}
8785

8886
record EphemeralPurgeNotifInfo {
@@ -106,10 +104,6 @@ protocol NotifyChat {
106104
array<UIMessage> updates;
107105
}
108106

109-
record ConvsUpdated {
110-
array<InboxUIItem> items;
111-
}
112-
113107
variant ChatActivity switch (ChatActivityType activityType) {
114108
case INCOMING_MESSAGE: IncomingMessage;
115109
case READ_MESSAGE: ReadMessageInfo;
@@ -123,7 +117,6 @@ protocol NotifyChat {
123117
case EPHEMERAL_PURGE: EphemeralPurgeNotifInfo;
124118
case REACTION_UPDATE: ReactionUpdateNotif;
125119
case MESSAGES_UPDATED: MessagesUpdated;
126-
case CONVS_UPDATED: ConvsUpdated;
127120
}
128121

129122
record TyperInfo {

‎protocol/json/chat1/notify.json‎

Lines changed: 1 addition & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎shared/actions/chat2-gen.tsx‎

Lines changed: 0 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)