Skip to content

Commit

Permalink
GetUnverifiedConv in each thread
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblum committed Aug 28, 2019
1 parent 20b0528 commit a95b92d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions go/chat/uithreadloader.go
Expand Up @@ -440,10 +440,6 @@ func (t *UIThreadLoader) LoadNonblock(ctx context.Context, chatUI libkb.ChatUI,
if pagination != nil && pagination.Last {
return nil
}
conv, ierr := utils.GetUnverifiedConv(ctx, t.G(), uid, convID, types.InboxSourceDataSourceAll)
if ierr != nil {
return ierr
}

// Race the full operation versus the local one, so we don't lose anytime grabbing the local
// version if they are roughly as fast. However, the full operation has preference, so if it does
Expand Down Expand Up @@ -512,6 +508,11 @@ func (t *UIThreadLoader) LoadNonblock(ctx context.Context, chatUI libkb.ChatUI,
}
var pthread *string
if resThread != nil {
conv, err := utils.GetUnverifiedConv(ctx, t.G(), uid, convID, types.InboxSourceDataSourceLocalOnly)
if err != nil {
t.Debug(ctx, "LoadNonblock: failed to GetUnverifiedConv localonly: %v", err)
return
}
*resThread = t.groupThreadView(ctx, uid, *resThread, conv)
t.Debug(ctx, "LoadNonblock: sending cached response: messages: %d pager: %s",
len(resThread.Messages), resThread.Pagination)
Expand Down Expand Up @@ -540,6 +541,7 @@ func (t *UIThreadLoader) LoadNonblock(ctx context.Context, chatUI libkb.ChatUI,
getDelay := func() time.Duration {
return baseDelay - (t.clock.Now().Sub(startTime))
}
var rconv types.RemoteConversation
wg.Add(1)
go func() {
defer wg.Done()
Expand All @@ -561,7 +563,11 @@ func (t *UIThreadLoader) LoadNonblock(ctx context.Context, chatUI libkb.ChatUI,
uilock.Lock()
defer uilock.Unlock()
var rthread chat1.ThreadView
remoteThread = t.groupThreadView(ctx, uid, remoteThread, conv)
rconv, fullErr = utils.GetUnverifiedConv(ctx, t.G(), uid, convID, types.InboxSourceDataSourceAll)
if fullErr != nil {
return
}
remoteThread = t.groupThreadView(ctx, uid, remoteThread, rconv)
if rthread, fullErr =
t.mergeLocalRemoteThread(ctx, &remoteThread, localSentThread, cbmode); fullErr != nil {
return
Expand Down Expand Up @@ -630,7 +636,8 @@ func (t *UIThreadLoader) LoadNonblock(ctx context.Context, chatUI libkb.ChatUI,
if len(changed) == 0 {
continue
}
if changed, ierr = t.G().ConvSource.TransformSupersedes(ctx, conv.Conv, uid, changed,
var ierr error
if changed, ierr = t.G().ConvSource.TransformSupersedes(ctx, rconv.Conv, uid, changed,
query, nil, nil); ierr != nil {
return ierr
}
Expand Down

0 comments on commit a95b92d

Please sign in to comment.