<miso-threads>
The list of the reader's chat threads, newest first. When the reader selects a
thread, it opens in <miso-conversation>. Here one list shows the starred
threads, and a second list shows the rest:
<miso-history class="miso-history">
<miso-new-thread></miso-new-thread>
<section class="miso-history__group miso-history__group--favorite">
<h3 class="miso-history__group-title">Favorites</h3>
<miso-threads group="favorite"></miso-threads>
</section>
<section class="miso-history__group">
<h3 class="miso-history__group-title">Recents</h3>
<miso-threads group="unfavorite"></miso-threads>
</section>
</miso-history>
Containers
| Container | Layout |
|---|---|
<miso-history> | threads |
threads is the only layout for this element. The options below go to
useLayouts on client.ui.history, under the role threads.
Attributes
group
Since 1.14.2
Chooses which threads the list shows:
| Value | The list shows |
|---|---|
| Attribute left out | Every thread. |
favorite | The threads the reader starred. |
unfavorite | The threads the reader did not star. |
Any other value shows every thread. The list reads group when it renders, so
write it in the HTML, or set it before you add the element to the page.
When the reader stars a thread, it moves from the unfavorite list to the
favorite list at once. If Miso rejects the change, the thread moves back.
Items
Each thread is a <miso-thread-item> with the title of the thread, a star and a
menu. The star and the three dots show when the pointer is on the item. A click
on the star adds the thread to the favorites, or removes it. The menu opens
from the three dots, and holds Rename, Subscribe or Unsubscribe,
and Delete. A thread with no title shows Untitled. On a new thread, the
star is disabled until Miso has saved the first question.
The SDK puts these attributes on each <miso-thread-item>, so you can style
the items from your CSS:
| Attribute | On a thread that |
|---|---|
data-selected | Is open in <miso-conversation>. |
data-unread | Is subscribed, and has an answer update. |
data-thread-id | Has a thread ID. The value is the ID. A thread that is still being created has no ID. |
miso-thread-item[data-unread] .miso-threads__title {
font-weight: 600;
}
The star and the menu items are elements of the thread, so you change their
labels on client.ui.history by their own roles. The star shows no text, so
its labels are for screen readers:
client.ui.history.useLayouts({
favorite: { ariaLabel: "Pin", checkedAriaLabel: "Unpin" },
rename: { text: "Edit title" },
subscription: { text: "Follow", checkedText: "Unfollow" },
delete: { text: "Remove" },
});
The color of a starred thread's star is the CSS variable
--miso-favorite-checked-color. See
<miso-favorite> for the star's options.
Loading
The list loads 100 threads of its group at a time. When the reader scrolls to the end of the list, it loads the next page of that group. To change the page size, see Number of threads.
A reader with no threads sees an empty list. To show a line in its place, put
an element with visible-when="ready+empty" next to it. See
Chat History — UI Customization.
Errors
When the list cannot load, a notice takes its place:
| Cause | Text |
|---|---|
| The session has expired (status 401) | "Your session has expired. Please sign in again." |
| Any other failure | "Your conversations could not be loaded." |
The errorMessage template returns the text. It gets (layout, error), and
error.status is the HTTP status:
client.ui.history.useLayouts({
threads: {
templates: {
errorMessage: (layout, error) =>
error && error.status === 401
? "Sign in again to see your chats."
: "We could not load your chats.",
},
},
});
Next
- Chat History — Quick Start: build the thread list and the open thread.
<miso-messages>: the messages of the open thread.
