@plteam/chat-ui
Version:
CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript
17 lines (16 loc) • 591 B
JavaScript
import { ObservableReactValue } from '../utils/observers';
import { arrayPluck } from '../utils/arrayUtils/arrayPluck';
export class ThreadListGroupItem {
data;
threads = new ObservableReactValue([]);
constructor(data) {
this.data = data;
}
checkList = (threads) => {
const newIds = arrayPluck(threads, 'id').sort().join('-');
const currentIds = arrayPluck(this.threads.value, 'id').sort().join('-');
if (newIds !== currentIds) {
this.threads.value = threads.sort((a, b) => b.time - a.time);
}
};
}