Fix types and remove omichannelsUpdate
This commit is contained in:
parent
71dc0b8f50
commit
4532a6929c
|
@ -105,7 +105,6 @@ interface IRoomsListViewState {
|
||||||
searching?: boolean;
|
searching?: boolean;
|
||||||
search?: IRoomItem[];
|
search?: IRoomItem[];
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
omnichannelsUpdate?: string[];
|
|
||||||
chats?: IRoomItem[];
|
chats?: IRoomItem[];
|
||||||
item?: ISubscription;
|
item?: ISubscription;
|
||||||
canCreateRoom?: boolean;
|
canCreateRoom?: boolean;
|
||||||
|
@ -158,7 +157,6 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
||||||
searching: false,
|
searching: false,
|
||||||
search: [],
|
search: [],
|
||||||
loading: true,
|
loading: true,
|
||||||
omnichannelsUpdate: [],
|
|
||||||
chats: [],
|
chats: [],
|
||||||
item: {} as ISubscription,
|
item: {} as ISubscription,
|
||||||
canCreateRoom: false
|
canCreateRoom: false
|
||||||
|
@ -372,7 +370,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
||||||
this.setState(state, callback);
|
this.setState(state, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
addRoomsGroup = (data: TSubscriptionModel[] | any, header: string, allData: TSubscriptionModel[]) => {
|
addRoomsGroup = (data: ISubscription[], header: string, allData: ISubscription[]) => {
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
if (header) {
|
if (header) {
|
||||||
allData.push({ rid: header, separator: true } as TSubscriptionModel);
|
allData.push({ rid: header, separator: true } as TSubscriptionModel);
|
||||||
|
@ -414,18 +412,15 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
||||||
}
|
}
|
||||||
|
|
||||||
this.querySubscription = observable.subscribe(data => {
|
this.querySubscription = observable.subscribe(data => {
|
||||||
console.log('update query');
|
let tempChats: ISubscription[] = [];
|
||||||
let tempChats = [] as TSubscriptionModel[];
|
|
||||||
let chats = data.map(item => item.asPlain());
|
let chats = data.map(item => item.asPlain());
|
||||||
|
|
||||||
let omnichannelsUpdate: string[] = [];
|
|
||||||
const isOmnichannelAgent = user?.roles?.includes('livechat-agent');
|
const isOmnichannelAgent = user?.roles?.includes('livechat-agent');
|
||||||
if (isOmnichannelAgent) {
|
if (isOmnichannelAgent) {
|
||||||
const omnichannel = chats.filter(s => filterIsOmnichannel(s));
|
const omnichannel = chats.filter(s => filterIsOmnichannel(s));
|
||||||
const omnichannelInProgress = omnichannel.filter(s => !s.onHold);
|
const omnichannelInProgress = omnichannel.filter(s => !s.onHold);
|
||||||
const omnichannelOnHold = omnichannel.filter(s => s.onHold);
|
const omnichannelOnHold = omnichannel.filter(s => s.onHold);
|
||||||
chats = chats.filter(s => !filterIsOmnichannel(s));
|
chats = chats.filter(s => !filterIsOmnichannel(s));
|
||||||
omnichannelsUpdate = omnichannelInProgress.map(s => s.rid);
|
|
||||||
tempChats = this.addRoomsGroup(omnichannelInProgress, OMNICHANNEL_HEADER_IN_PROGRESS, tempChats);
|
tempChats = this.addRoomsGroup(omnichannelInProgress, OMNICHANNEL_HEADER_IN_PROGRESS, tempChats);
|
||||||
tempChats = this.addRoomsGroup(omnichannelOnHold, OMNICHANNEL_HEADER_ON_HOLD, tempChats);
|
tempChats = this.addRoomsGroup(omnichannelOnHold, OMNICHANNEL_HEADER_ON_HOLD, tempChats);
|
||||||
}
|
}
|
||||||
|
@ -457,13 +452,11 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
||||||
} else if (showUnread || showFavorites || isOmnichannelAgent) {
|
} else if (showUnread || showFavorites || isOmnichannelAgent) {
|
||||||
tempChats = this.addRoomsGroup(chats, CHATS_HEADER, tempChats);
|
tempChats = this.addRoomsGroup(chats, CHATS_HEADER, tempChats);
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore
|
|
||||||
tempChats = chats;
|
tempChats = chats;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.internalSetState({
|
this.internalSetState({
|
||||||
chats: tempChats,
|
chats: tempChats,
|
||||||
omnichannelsUpdate,
|
|
||||||
loading: false
|
loading: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue