forked from Mirrors/gomuks
hicli/paginate: fix handling non-empty final chunk
This commit is contained in:
parent
9c17ce001d
commit
87ec9d60a5
1 changed files with 3 additions and 3 deletions
|
@ -296,12 +296,12 @@ func (h *HiClient) PaginateServer(ctx context.Context, roomID id.RoomID, limit i
|
||||||
if resp.End == "" {
|
if resp.End == "" {
|
||||||
resp.End = database.PrevBatchPaginationComplete
|
resp.End = database.PrevBatchPaginationComplete
|
||||||
}
|
}
|
||||||
if resp.End == database.PrevBatchPaginationComplete || len(resp.Chunk) == 0 {
|
if len(resp.Chunk) == 0 {
|
||||||
err = h.DB.Room.SetPrevBatch(ctx, room.ID, resp.End)
|
err = h.DB.Room.SetPrevBatch(ctx, room.ID, resp.End)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to set prev_batch: %w", err)
|
return nil, fmt.Errorf("failed to set prev_batch: %w", err)
|
||||||
}
|
}
|
||||||
return &PaginationResponse{Events: events, HasMore: resp.End != ""}, nil
|
return &PaginationResponse{Events: events, HasMore: resp.End != database.PrevBatchPaginationComplete}, nil
|
||||||
}
|
}
|
||||||
wakeupSessionRequests := false
|
wakeupSessionRequests := false
|
||||||
err = h.DB.DoTxn(ctx, nil, func(ctx context.Context) error {
|
err = h.DB.DoTxn(ctx, nil, func(ctx context.Context) error {
|
||||||
|
@ -366,5 +366,5 @@ func (h *HiClient) PaginateServer(ctx context.Context, roomID id.RoomID, limit i
|
||||||
if err == nil && wakeupSessionRequests {
|
if err == nil && wakeupSessionRequests {
|
||||||
h.WakeupRequestQueue()
|
h.WakeupRequestQueue()
|
||||||
}
|
}
|
||||||
return &PaginationResponse{Events: events, HasMore: true}, err
|
return &PaginationResponse{Events: events, HasMore: resp.End != database.PrevBatchPaginationComplete}, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue