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

Webchat history #425

Merged
merged 3 commits into from
May 8, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
</head>

<body>
<temba-webchat channel="37d75001-62c5-465d-8a4b-4e7c0b34ffad"></temba-webchat>
<temba-store completion="/static/api/completion.json" functions="/static/api/functions.json"
fields="/static/api/fields.json" globals="/static/api/globals.json" groups="/static/api/groups.json"></temba-store>

Expand Down
11 changes: 7 additions & 4 deletions src/contacts/ContactHistory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css } from 'lit';
import { property } from 'lit/decorators.js';
import { html, TemplateResult } from 'lit-html';
import { Contact, CustomEventType, Msg, Ticket } from '../interfaces';
import { Contact, CustomEventType, Ticket } from '../interfaces';
import { RapidElement } from '../RapidElement';
import { Asset, getAssets, getClasses, postJSON, throttle } from '../utils';

Expand Down Expand Up @@ -42,7 +42,6 @@
renderResultEvent,
renderTicketAction,
renderTicketAssigned,
renderTicketOpened,
renderUpdateEvent,
renderWebhookEvent,
TicketEvent,
Expand Down Expand Up @@ -339,15 +338,19 @@
)[0];

forceOpen = sliced.open;
fetchedEvents.splice(0, 0, ...sliced.events);
if (sliced.events.length > 0) {
fetchedEvents.splice(0, 0, ...sliced.events);
}

Check warning on line 343 in src/contacts/ContactHistory.ts

View check run for this annotation

Codecov / codecov/patch

src/contacts/ContactHistory.ts#L341-L343

Added lines #L341 - L343 were not covered by tests
}

const grouped = this.getEventGroups(fetchedEvents);
if (grouped.length) {
if (forceOpen) {
grouped[grouped.length - 1].open = forceOpen;
}
this.eventGroups = [...previousGroups, ...grouped];
this.eventGroups = [...previousGroups, ...grouped].filter(
group => group.events.length > 0
);

Check warning on line 353 in src/contacts/ContactHistory.ts

View check run for this annotation

Codecov / codecov/patch

src/contacts/ContactHistory.ts#L351-L353

Added lines #L351 - L353 were not covered by tests
}
this.refreshing = false;
this.scheduleRefresh();
Expand Down
Loading
Loading