Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

have JS trigger meta reload on expunge #18931

Merged
merged 3 commits into from Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions go/chat/botcommands_test.go
Expand Up @@ -84,12 +84,9 @@ func TestBotCommandManager(t *testing.T) {
}
}
select {
case items := <-listener0.convsUpdated:
case items := <-listener0.threadsStale:
require.Equal(t, 1, len(items))
require.Equal(t, impConv.Id.String(), items[0].ConvID)
typ, err := items[0].BotCommands.Typ()
require.NoError(t, err)
require.Equal(t, chat1.ConversationCommandGroupsTyp_CUSTOM, typ)
require.Equal(t, impConv.Id, items[0].ConvID)
case <-time.After(timeout):
require.Fail(t, "no stale")
}
Expand Down
18 changes: 5 additions & 13 deletions go/chat/bots/commands.go
Expand Up @@ -16,7 +16,6 @@ import (

"github.com/keybase/client/go/chat/globals"
"github.com/keybase/client/go/chat/storage"
"github.com/keybase/client/go/chat/types"
"github.com/keybase/client/go/chat/utils"
"github.com/keybase/client/go/libkb"
"github.com/keybase/client/go/protocol/chat1"
Expand Down Expand Up @@ -415,19 +414,12 @@ func (b *CachingBotCommandManager) commandUpdate(ctx context.Context, job comman
if err := storage.NewInbox(b.G()).IncrementLocalConvVersion(ctx, b.uid, job.convID); err != nil {
b.Debug(ctx, "commandUpdate: unable to IncrementLocalConvVersion, err", err)
}
conv, err := utils.GetVerifiedConv(ctx, b.G(), b.uid, job.convID, types.InboxSourceDataSourceAll)
if err != nil {
return err
}
username, err := b.getMyUsername(ctx)
if err != nil {
return err
}
act := chat1.NewChatActivityWithConvsUpdated(chat1.ConvsUpdated{
Items: []chat1.InboxUIItem{utils.PresentConversationLocal(ctx, conv, username)},
b.G().ActivityNotifier.ThreadsStale(ctx, b.uid, []chat1.ConversationStaleUpdate{
{
ConvID: job.convID,
UpdateType: chat1.StaleUpdateType_CONVUPDATE,
},
})
b.G().ActivityNotifier.Activity(ctx, b.uid, chat1.TopicType_CHAT, &act,
chat1.ChatActivitySource_LOCAL)
return nil
}

Expand Down
22 changes: 15 additions & 7 deletions go/chat/convsource.go
Expand Up @@ -866,21 +866,29 @@ func (s *HybridConversationSource) GetUnreadline(ctx context.Context,
func (s *HybridConversationSource) notifyExpunge(ctx context.Context, uid gregor1.UID,
convID chat1.ConversationID, mergeRes storage.MergeResult) {
if mergeRes.Expunged != nil {
var inboxItem *chat1.InboxUIItem
topicType := chat1.TopicType_NONE
conv, err := utils.GetVerifiedConv(ctx, s.G(), uid, convID, types.InboxSourceDataSourceAll)
if err != nil {
s.Debug(ctx, "notifyExpunge: failed to get conversations: %s", err)
} else {
inboxItem = PresentConversationLocalWithFetchRetry(ctx, s.G(), uid, conv)
topicType = conv.GetTopicType()
}
act := chat1.NewChatActivityWithExpunge(chat1.ExpungeInfo{
ConvID: convID,
Expunge: *mergeRes.Expunged,
Conv: inboxItem,
})
s.G().ActivityNotifier.Activity(ctx, uid, topicType, &act, chat1.ChatActivitySource_LOCAL)

// update inbox info as well
if err := storage.NewInbox(s.G()).IncrementLocalConvVersion(ctx, uid, convID); err != nil {
s.Debug(ctx, "notifyExpunge: unable to IncrementLocalConvVersion, err", err)
}
s.G().ActivityNotifier.ThreadsStale(ctx, uid, []chat1.ConversationStaleUpdate{
{
ConvID: convID,
UpdateType: chat1.StaleUpdateType_CONVUPDATE,
},
})
}
}

Expand All @@ -891,18 +899,18 @@ func (s *HybridConversationSource) notifyUpdated(ctx context.Context, uid gregor
return
}
s.Debug(ctx, "notifyUpdated: notifying %d messages", len(msgs))
conv, err := utils.GetUnverifiedConv(ctx, s.G(), uid, convID, types.InboxSourceDataSourceAll)
conv, err := utils.GetVerifiedConv(ctx, s.G(), uid, convID, types.InboxSourceDataSourceAll)
if err != nil {
s.Debug(ctx, "notifyUpdated: failed to get conv: %s", err)
return
}
updatedMsgs, err := s.TransformSupersedes(ctx, conv.Conv, uid, msgs, nil, nil, nil)
updatedMsgs, err := s.TransformSupersedes(ctx, conv, uid, msgs, nil, nil, nil)
if err != nil {
s.Debug(ctx, "notifyUpdated: failed to transform supersedes: %s", err)
return
}
s.Debug(ctx, "notifyUpdated: %d messages after transform", len(updatedMsgs))
if updatedMsgs, err = NewReplyFiller(s.G()).Fill(ctx, uid, conv.Conv, updatedMsgs); err != nil {
if updatedMsgs, err = NewReplyFiller(s.G()).Fill(ctx, uid, conv, updatedMsgs); err != nil {
s.Debug(ctx, "notifyUpdated: failed to fill replies %s", err)
return
}
Expand All @@ -913,7 +921,7 @@ func (s *HybridConversationSource) notifyUpdated(ctx context.Context, uid gregor
notif.Updates = append(notif.Updates, utils.PresentMessageUnboxed(ctx, s.G(), msg, uid, convID))
}
act := chat1.NewChatActivityWithMessagesUpdated(notif)
s.G().ActivityNotifier.Activity(ctx, uid, chat1.TopicType_CHAT,
s.G().ActivityNotifier.Activity(ctx, uid, conv.GetTopicType(),
&act, chat1.ChatActivitySource_LOCAL)
}

Expand Down
4 changes: 0 additions & 4 deletions go/chat/server_test.go
Expand Up @@ -2017,7 +2017,6 @@ type serverChatListener struct {
reactionUpdate chan chat1.ReactionUpdateNotif
messagesUpdated chan chat1.MessagesUpdated
readMessage chan chat1.ReadMessageInfo
convsUpdated chan []chat1.InboxUIItem

threadsStale chan []chat1.ConversationStaleUpdate
inboxStale chan struct{}
Expand Down Expand Up @@ -2086,8 +2085,6 @@ func (n *serverChatListener) NewChatActivity(uid keybase1.UID, activity chat1.Ch
n.messagesUpdated <- activity.MessagesUpdated()
case chat1.ChatActivityType_SET_STATUS:
n.setStatus <- activity.SetStatus()
case chat1.ChatActivityType_CONVS_UPDATED:
n.convsUpdated <- activity.ConvsUpdated().Items
}
}
func (n *serverChatListener) ChatJoinedConversation(uid keybase1.UID, convID chat1.ConversationID,
Expand Down Expand Up @@ -2149,7 +2146,6 @@ func newServerChatListener() *serverChatListener {
ephemeralPurge: make(chan chat1.EphemeralPurgeNotifInfo, buf),
reactionUpdate: make(chan chat1.ReactionUpdateNotif, buf),
messagesUpdated: make(chan chat1.MessagesUpdated, buf),
convsUpdated: make(chan []chat1.InboxUIItem, buf),

threadsStale: make(chan []chat1.ConversationStaleUpdate, buf),
inboxStale: make(chan struct{}, buf),
Expand Down
61 changes: 0 additions & 61 deletions go/protocol/chat1/notify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions protocol/avdl/chat1/notify.avdl
Expand Up @@ -22,8 +22,7 @@ protocol NotifyChat {
EXPUNGE_9,
EPHEMERAL_PURGE_10,
REACTION_UPDATE_11,
MESSAGES_UPDATED_12,
CONVS_UPDATED_13
MESSAGES_UPDATED_12
}

record IncomingMessage {
Expand Down Expand Up @@ -82,7 +81,6 @@ protocol NotifyChat {
record ExpungeInfo {
ConversationID convID;
Expunge expunge;
union { null, InboxUIItem } conv;
}

record EphemeralPurgeNotifInfo {
Expand All @@ -106,10 +104,6 @@ protocol NotifyChat {
array<UIMessage> updates;
}

record ConvsUpdated {
array<InboxUIItem> items;
}

variant ChatActivity switch (ChatActivityType activityType) {
case INCOMING_MESSAGE: IncomingMessage;
case READ_MESSAGE: ReadMessageInfo;
Expand All @@ -123,7 +117,6 @@ protocol NotifyChat {
case EPHEMERAL_PURGE: EphemeralPurgeNotifInfo;
case REACTION_UPDATE: ReactionUpdateNotif;
case MESSAGES_UPDATED: MessagesUpdated;
case CONVS_UPDATED: ConvsUpdated;
}

record TyperInfo {
Expand Down
30 changes: 1 addition & 29 deletions protocol/json/chat1/notify.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion shared/actions/chat2-gen.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.