Skip to content

Commit

Permalink
re layout in first conv if it is the first message (#20115)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaxim committed Oct 3, 2019
1 parent 18a3ec2 commit b99d5cd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions go/chat/storage/inbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ type SharedInboxItem struct {
type InboxLayoutChangedNotifier interface {
UpdateLayout(ctx context.Context, reason string) error
UpdateLayoutFromNewMessage(ctx context.Context, conv types.RemoteConversation,
msgType chat1.MessageType, firstConv bool) error
msg chat1.MessageBoxed, firstConv bool) error
UpdateLayoutFromSubteamRename(ctx context.Context, convs []types.RemoteConversation) error
}

Expand All @@ -104,7 +104,7 @@ func (d dummyInboxLayoutChangedNotifier) UpdateLayout(ctx context.Context, reaso
}

func (d dummyInboxLayoutChangedNotifier) UpdateLayoutFromNewMessage(ctx context.Context,
conv types.RemoteConversation, msgType chat1.MessageType, firstConv bool) error {
conv types.RemoteConversation, msg chat1.MessageBoxed, firstConv bool) error {
return nil
}

Expand Down Expand Up @@ -920,8 +920,8 @@ func (i *Inbox) NewConversation(ctx context.Context, uid gregor1.UID, vers chat1
}
}

// Add the convo
layoutChanged = conv.GetTopicType() == chat1.TopicType_CHAT // only chat convs change layout
// only chat convs for layout changed
layoutChanged = layoutChanged || conv.GetTopicType() == chat1.TopicType_CHAT
ibox.Conversations = append(utils.RemoteConvs([]chat1.Conversation{conv}), ibox.Conversations...)
} else {
i.Debug(ctx, "NewConversation: skipping update, conversation exists in inbox")
Expand Down Expand Up @@ -1159,7 +1159,7 @@ func (i *Inbox) NewMessage(ctx context.Context, uid gregor1.UID, vers chat1.Inbo
if mconv.GetTopicType() == chat1.TopicType_CHAT {
defer func() {
go func(ctx context.Context) {
_ = i.layoutNotifier.UpdateLayoutFromNewMessage(ctx, mconv, msg.GetMessageType(), index == 0)
_ = i.layoutNotifier.UpdateLayoutFromNewMessage(ctx, mconv, msg, index == 0)
}(globals.BackgroundChatCtx(ctx, i.G()))
}()
}
Expand Down
2 changes: 1 addition & 1 deletion go/chat/types/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ type UIInboxLoader interface {
Resumable
UpdateLayout(ctx context.Context, reason string) error
UpdateLayoutFromNewMessage(ctx context.Context, conv RemoteConversation,
msgType chat1.MessageType, firstConv bool) error
msg chat1.MessageBoxed, firstConv bool) error
UpdateLayoutFromSubteamRename(ctx context.Context, convs []RemoteConversation) error
UpdateConvs(ctx context.Context, convIDs []chat1.ConversationID) error
LoadNonblock(ctx context.Context, query *chat1.GetInboxLocalQuery,
Expand Down
2 changes: 1 addition & 1 deletion go/chat/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ func (d DummyUIInboxLoader) UpdateConvs(ctx context.Context, convIDs []chat1.Con
}

func (d DummyUIInboxLoader) UpdateLayoutFromNewMessage(ctx context.Context, conv RemoteConversation,
msgType chat1.MessageType, firstConv bool) error {
msg chat1.MessageBoxed, firstConv bool) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions go/chat/uiinboxloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,13 @@ func (h *UIInboxLoader) UpdateLayout(ctx context.Context, reason string) (err er
}

func (h *UIInboxLoader) UpdateLayoutFromNewMessage(ctx context.Context, conv types.RemoteConversation,
msgType chat1.MessageType, firstConv bool) (err error) {
msg chat1.MessageBoxed, firstConv bool) (err error) {
defer h.Trace(ctx, func() error { return err }, "UpdateLayoutFromNewMessage")()
if conv.GetTeamType() == chat1.TeamType_COMPLEX {
h.Debug(ctx, "UpdateLayoutFromNewMessage: skipping layout for big team")
return nil
}
if firstConv {
if firstConv && msg.GetMessageID() > 2 {
h.Debug(ctx, "UpdateLayoutFromNewMessage: skipping layout on first conv change")
return nil
}
Expand Down

0 comments on commit b99d5cd

Please sign in to comment.