Commit cb9b043c authored by Fernando Takagi's avatar Fernando Takagi
Browse files

Add previous cursor to console chat page.

parent 947a38e0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@
      <div class="btn-group page-btns" role="group" aria-label="Basic example">
        <button type="button" class="btn btn-outline-secondary" (click)="search(0)" [disabled]="messages.length === 0">
          <img src="/static/svg/page-first.svg" alt="" width="20" height=""></button>
        <button type="button" class="btn btn-outline-secondary" (click)="search(-1)" [disabled]="prevCursor === '' || prevCursor === null"><img
          src="/static/svg/page-prev.svg" alt="" width="20" height=""></button>
        <button type="button" class="btn btn-outline-secondary" (click)="search(1)" [disabled]="nextCursor === '' || nextCursor === null"><img
          src="/static/svg/page-next.svg" alt="" width="20" height=""></button>
      </div>
+6 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ export class ChatListComponent implements OnInit {
  public readonly systemUserId = '00000000-0000-0000-0000-000000000000';
  public error = '';
  public messages: Array<ApiChannelMessage> = [];
  public prevCursor = '';
  public nextCursor = '';
  public searchForm1: FormGroup;
  public searchForm2: FormGroup;
@@ -88,6 +89,7 @@ export class ChatListComponent implements OnInit {
            this.messages.length = 0;
            this.messages.push(...d[0].messages);
            this.nextCursor = d[0].next_cursor;
            this.prevCursor = d[0].prev_cursor;
          }
          if (d.error) {
            this.error = d.error;
@@ -119,6 +121,9 @@ export class ChatListComponent implements OnInit {
      case 1:
        cursor = this.nextCursor;
        break;
      case -1:
        cursor = this.prevCursor;
        break;
    }
    this.updateMessages(this.type, this.f1.label.value, this.f2.group_id.value,
      this.f3.user_id_one.value, this.f3.user_id_two.value, cursor)
@@ -148,6 +153,7 @@ export class ChatListComponent implements OnInit {
    this.messages.length = 0;
    this.messages.push(...d.messages);
    this.nextCursor = d.next_cursor;
    this.prevCursor = d.prev_cursor;

    let params: Params;
    switch(this.type) {
+2 −1
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ func (s *ConsoleServer) ListChannelMessages(ctx context.Context, in *console.Lis
		return nil, status.Error(codes.InvalidArgument, "Cursor is invalid or expired.")
	}

	messageList, err := ChannelMessagesList(ctx, s.logger, s.db, uuid.Nil, *stream, channelId, limit, false, cursor, nil)
	haystack := time.Unix(in.HaystackSec, 0).UTC()
	messageList, err := ChannelMessagesList(ctx, s.logger, s.db, uuid.Nil, *stream, channelId, limit, in.Forward, cursor, &haystack)
	if err == runtime.ErrChannelCursorInvalid {
		return nil, status.Error(codes.InvalidArgument, "Cursor is invalid or expired.")
	} else if err != nil {