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

[IMPROVE][Omnichannel] More info and better design of Past Chats List #17346

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7ac2a47
Add all the features
nitinkumartiwari Apr 17, 2020
428c047
css improved
nitinkumartiwari Apr 17, 2020
cf71487
changed some css
nitinkumartiwari Apr 17, 2020
759eaff
Merge branch 'develop' into refactor-past-chat-history
renatobecker Apr 18, 2020
faaa0e8
Merge branch 'develop' into refactor-past-chat-history
renatobecker Apr 21, 2020
1dd9fae
Code and CSS Improvement
nitinkumartiwari Apr 22, 2020
19d6184
Code and CSS Improvement
nitinkumartiwari Apr 22, 2020
2650e56
Merge branch 'refactor-past-chat-history' of https://github.com/nitin…
nitinkumartiwari Apr 22, 2020
8388d6e
some changes
nitinkumartiwari Apr 22, 2020
6ec867f
changes made
nitinkumartiwari Apr 22, 2020
65d03ae
Api modified
nitinkumartiwari Apr 27, 2020
45ee0dd
css changes with Api modification
nitinkumartiwari Apr 27, 2020
4a7e476
chnages made on 28April
nitinkumartiwari Apr 28, 2020
2996e42
changes made on 1may
nitinkumartiwari May 1, 2020
63ee375
changes made on 6th may
nitinkumartiwari May 6, 2020
1450021
css chang
nitinkumartiwari May 6, 2020
866130c
css chang
nitinkumartiwari May 6, 2020
ff89afc
css chang
nitinkumartiwari May 6, 2020
74e51a6
css chang
nitinkumartiwari May 6, 2020
efee120
css chang
nitinkumartiwari May 6, 2020
3cf7fa9
css chang
nitinkumartiwari May 6, 2020
845b7e9
css chang
nitinkumartiwari May 6, 2020
36e5ad7
changes made on 7th may
nitinkumartiwari May 7, 2020
57d6457
Merge branch 'develop' into refactor-past-chat-history
renatobecker Jun 1, 2020
587cd3d
Update visitors.js
renatobecker Jun 1, 2020
048c1d4
Fix indentations.
renatobecker Jun 1, 2020
6e14f32
Fix css/style issues.
renatobecker Jun 2, 2020
7db6ce0
Merge branch 'develop' into refactor-past-chat-history
renatobecker Jun 2, 2020
685a770
Merge branch 'develop' into refactor-past-chat-history
renatobecker Jun 2, 2020
7317eac
Merge branch 'develop' into refactor-past-chat-history
renatobecker Jun 15, 2020
12111e1
Refactored the codebase.
renatobecker Jun 16, 2020
9536f15
Fix unused imports.
renatobecker Jun 16, 2020
c0990b2
Fix CSS file.
renatobecker Jun 16, 2020
9607da0
Merge branch 'develop' into refactor-past-chat-history
renatobecker Jun 16, 2020
b5ed51a
Add new query to fetch chat history.
renatobecker Jun 17, 2020
1e98343
Remove unnecessary console log.
renatobecker Jun 17, 2020
0e4bc40
UI-UX improvements.
renatobecker Jun 18, 2020
127132e
Fix Css stuff.
renatobecker Jun 18, 2020
bba74e3
Fix fetch data.
renatobecker Jun 18, 2020
0dacdf9
Merge branch 'develop' into refactor-past-chat-history
renatobecker Jun 18, 2020
9d2e42e
Remove unnecessary helper method.
renatobecker Jun 18, 2020
a6d8ef4
Final version.
renatobecker Jun 19, 2020
5d28d35
Fix empty-line missing.
renatobecker Jun 19, 2020
26a5c98
Additional improvements.
renatobecker Jun 19, 2020
0632ee2
Merge branch 'develop' into refactor-past-chat-history
renatobecker Jun 19, 2020
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
2 changes: 1 addition & 1 deletion app/livechat/client/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TabBar.addButton({
id: 'visitor-history',
i18nTitle: 'Past_Chats',
icon: 'clock',
template: 'visitorHistory',
template: 'customerChatHistory',
order: 11,
});

Expand Down
26 changes: 26 additions & 0 deletions app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template name='chatRoomHistoryItem'>
<li class='list-chat' id='{{_id}}' aria='{{v.token}}' >
<div class="history-div">
<div class="visitor-img">
<img src="/avatar/{{responseBy.username}}" alt="">
</div>
<div class="visitor-history-details">
<div class="visitor-details">
<h1>{{responseBy.username}}</h1>
{{#if open}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template will only display closed conversations, so this if condition does not make sense.
Please, remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

<p class='open'>Open</p>
{{else}}
<p>Close at time {{time}}</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a helper method to return the formatted closedAt field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{{/if}}
</div>
<div class="total-messages">
<p>{{room.msgs}} messages</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>{{room.msgs}} messages</p>
<p>{{msgs}} messages</p>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done but this also includes the one as a connected message and one as a promptscript so there will be always +2 then the original message

</div>
<div class="agent-comment">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closing room message is not mandatory, there is a setting that forces the agent to leave a message when closing the conversation. So, this block of code is conditional, the template will need to provide a helper method that will be used to check if the closing message exists or not.
Something like:

  • hasClosingRoomMessage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<p class="comment-heading">Agent comment:</p>
<p class="comment-text">"{{lastMessage.msg}}"</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lastMessage.msg is not the message that will be displayed here. The closing room message needs to be fetched from the DB, so you will need a helper method to return the message to the template.

Suggested change
<p class="comment-text">"{{lastMessage.msg}}"</p>
<p class="comment-text">"{{closingRoomMessage}}"</p>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

performed a check if the lastMesaage is livechat-close message only then it will be displayed

</div>
</div>
</div>
</li>
</template>
55 changes: 55 additions & 0 deletions app/livechat/client/views/app/tabbar/customerChatHistory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template name='customerChatHistory'>
<div class="content">
<div class="list-view">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check if the customer already has chat history, if not, let's display a message.

Suggested change
<div class="list-view">
{{#if chatHistoryEmpty}}
{{_ "Customer_has_no_chat_history"}}
{{else}}
<div class="list-view">

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a check if there is chat history available or not

<div>
<div class="active-pink-4 mb-4 inner-addon right-addon">
<i class="glyphicon glyphicon-search icon-search"></i>
<input type="text" id="searchInput" class="" placeholder="Search" aria-label="Search">
</div>
</div>
{{#if hasChatHistory}}
{{#if isAllChat}}
<div class="vistior-history-block">
<ul id='allist'>
{{#if isSearching}}
{{#if isfound }}
{{#each searchResults}}
<li class='search-li'>
<div class="history-main">
<div class="history-img">
<img src="/avatar/{{u.username}}" >
</div>
<div class="history-detail-main">
<div class="detail-main-upper">
<h1>{{u.name}}</h1>
<p>{{time}}</p>
</div>
<div class="detail-main-lower">
<p>{{msg}}</p>
</div>
</div>
</div>
</li>
{{/each}}
{{else}}
<h1 class='noresult'>No result found</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add the translated string value here instead of a hardcoded "No result found".

Suggested change
<h1 class='noresult'>No result found</h1>
<h1 class='noresult'>{{_ "No_results_found"}}</h1>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{{/if}}
{{else}}
{{#each room in previousChats}}
{{> chatRoomHistoryItem room}}
{{/each}}
{{/if}}
</ul>
</div>
{{else}}
{{#if isChatClicked}}
{{> customerChatHistoryMessages}}
{{/if}}
{{/if}}
{{else}}
<h1 class='noresult'>No Previous Chats found</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add the translated string value here instead of a hardcoded "No Previous Chats found".
Also, add the correct translate value to the en.i18n.json file.

Suggested change
<h1 class='noresult'>No Previous Chats found</h1>
<h1 class='noresult'>{{_ "No_Previous_Chats_Found"}}</h1>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{{/if}}
</div>
</div>
</template>

161 changes: 161 additions & 0 deletions app/livechat/client/views/app/tabbar/customerChatHistory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import { Template } from 'meteor/templating';
import moment from 'moment';
import { ReactiveVar } from 'meteor/reactive-var';
import './customerChatHistory.html';
import './chatRoomHistoryItem.html';
import { APIClient, t } from '../../../../../utils/client';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

't' is defined but never used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

import { Session } from 'meteor/session';
import _ from 'underscore';
const ITEMS_COUNT = 50;
let isChanged;
Template.customerChatHistory.helpers({

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all of the blank lines like this.

hasChatHistory() {
// will return if user has any chatHistory or not
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need comments in all helper methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

return Template.instance().hasHistory.get()
},
isSearching() {
return Template.instance().isSearching.get()
},
isAllChat() {
// will return is have to load all chat
return Template.instance().isAllChat.get();
},
isChatClicked() {
// will return that if you have clicked in a single chatHistory
return Template.instance().isChatClicked.get();
},
isfound() {
// will return if find any search result
return Session.get('found');
},
searchResults(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have removed it

// will return search result
return Template.instance().searchResult.get();
},
previousChats() {
// will return pervious chats list
return addTime(Template.instance().history.get(),'true');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My editor(VS CODE) is displaying this => "'addTime' is not defined".
Do you guys have the ESLint installed on your code editor?

In addition, this is happening because the addTime method is declared without context, there is no const assigned, etc.

In addition, you don't need that function(addTime). You have created a new template -> chatRoomHistoryItem, right? So, what you need to do is to add this as a helper method in that template, you don't need this method here in this template.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

},
title() {

let title = moment(this.ts).format('L LTS');

if (this.label) {
title += ` - ${ this.label }`;
}
return title;
},
});

const DEBOUNCE_TIME_FOR_SEARCH_DEPARTMENTS_IN_MS = 300;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not using this const anywhere, you aren't applying the debounce on the method keyup #searchInput.
You need to do something like:

    ...
	'keyup #searchInput': _.debounce((e, t) => {
		e.stopPropagation();
		e.preventDefault();
		// your-code-here...        
	}, DEBOUNCE_TIME_FOR_SEARCH_CHATS_IN_MS),
    

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using a correct name for this CONST?
DEBOUNCE_TIME_FOR_SEARCH_DEPARTMENTS_IN_MS -> DEBOUNCE_TIME_FOR_SEARCH_CHATS_IN_MS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Template.customerChatHistory.onCreated(function() {
isChanged = false;
const currentData = Template.currentData();
this.filter = new ReactiveVar('');
this.hasHistory = new ReactiveVar(false);
this.visitorId = new ReactiveVar();
this.history = new ReactiveVar([]);
this.offset = new ReactiveVar(0);
this.total = new ReactiveVar(0);
this.isAllChat = new ReactiveVar(true);
this.isSearching = new ReactiveVar(false);
this.isChatClicked = new ReactiveVar(true);
this.autorun(async () => {
const { room } = await APIClient.v1.get(`rooms.info?roomId=${ currentData.rid }`);
if (room && room.v) {
this.visitorId.set(room.v._id);
}
});
this.autorun(async () => {
const filter = this.filter.get()
if (!this.visitorId.get() || !currentData || !currentData.rid) {
return;
}
const offset = this.offset.get();
const searchText='null';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const searchText='null';
const searchText='null';

Please, don't do this. You just need to declare the loadRooms(searchTerm) method inside the customerChatHistory.onCreated method, just like this:

	this.loadRooms(searchTerm) { ...

Inside this method, you will call the endpoint, and then you'll just apply a ternary operator to add the search term as parameters only when necessary.

let baseUrl = `livechat/visitors.chatHistory/room/${ currentData.rid}/visitor/${ this.visitorId.get() }?searchText=${searchText}&count=${ ITEMS_COUNT }&offset=${ offset }`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this code inside the this.loadRooms(searchTerm) method.

Suggested change
let baseUrl = `livechat/visitors.chatHistory/room/${ currentData.rid}/visitor/${ this.visitorId.get() }?searchText=${searchText}&count=${ ITEMS_COUNT }&offset=${ offset }`
let baseUrl = `livechat/visitors.chatHistory/room/${ currentData.rid}/visitor/${ this.visitorId.get() }?count=${ ITEMS_COUNT }&offset=${ offset }`

this.loadRooms(searchTerm) {
instance.ready.set(false);

let baseUrl = `livechat/visitors.chatHistory/room/${ currentData.rid}/visitor/${ this.visitorId.get() }?count=${ ITEMS_COUNT }&offset=${ offset }`

if (searchTerm) {
	baseUrl += `&searchText=${ searchTerm }`;
}

const { history, total } = await APIClient.v1.get(baseUrl);
this.history.set(this.history.get().concat(history));	
this.total.set(total);
thisready.set(true);

};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const { history, total,resultArray } = await APIClient.v1.get(baseUrl);
if(history.length > 0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this. What you need to do is:

  • Add an additional parameter to the endpoint, closedChatsOnly, then you will pass this parameter here which means that the server will only return closed chats and you won't need to check it on the client-side.
  • this.hasHistory.set(history.length > 0);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now i am doing this on server side

for(var i=0 ;i<history.length; i++){
if(!history[i].open){
this.hasHistory.set(true);
}
}
}
this.total.set(total);
this.history.set(this.history.get().concat(history));
});
});

Template.customerChatHistory.events({
'scroll .visitor-scroll': _.throttle(function(e, instance) {
if (e.target.scrollTop >= (e.target.scrollHeight - e.target.clientHeight)) {
const history = instance.history.get();
if (instance.total.get() <= history.length) {
return;
}
return instance.offset.set(instance.offset.get() + ITEMS_COUNT);
}
}, 200),
'keyup #searchInput': async function(event,template){
const offset = template.offset.get();
template.isSearching.set(true);
template.isChatClicked.set(false);
template.isAllChat.set(true);
Session.set('found',false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this? I didn't get yet why you're using sessions inside the templates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now i am not using session anywhere

if(event.target.value == ''){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this if/else statement.
Improve the loadRooms method following my previous suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have performed check on loadRoom method and removed it from here

template.isSearching.set(false);
}else{
Template.instance().searchResult = new ReactiveVar([]);
var result = loadRoom(event.target.value ,Template.currentData().rid,template.visitorId.get(),offset)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just need to pass the search term value through the loadRooms method.
If you need the additional fields you can get it from the ReactiveVars that store that information.

Suggested change
var result = loadRoom(event.target.value ,Template.currentData().rid,template.visitorId.get(),offset)
loadRoom(event.target.value);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now only search term is passing on loadRoom method

result.then(function(v){
if(v != null){
Session.set('found',true);
Session.set('searchResult',v);
template.searchResult.set(v);
}
})
}},
'click .list-chat': async function(event,template){
Copy link
Contributor

@renatobecker renatobecker Apr 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you just need to get the roomId will be used to fetch the customer history messages.
My suggestion is to have a property to define when you click on a room in the list, very similar to what you do with the isChatClicked, but you can use a better name.
Also, you can store the roomId of the clicked room in another property and pass this value to the Customer Chat History Messages template.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am getting the Room Id and token and storing into the session and getting from the customer chat history messages

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ReactiveVars to store this information, not sessions.

event.preventDefault();
template.isAllChat.set(false);
template.isChatClicked.set(true);
let id = event.currentTarget.id
let token = event.currentTarget.attributes.aria.value;
Session.set('FetchID',id);
Session.set('FetchToken',token)
}

});

Template.customerChatHistory.onDestroyed(function(){
var header = document.getElementsByClassName('Contextualheading');
if(header[0]){
header[0].innerText = ''
header[0].className = 'contextual-bar__header-title';
}
})

loadRoom = async (searchTerm,rid,visitorId,offset) =>{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned before, move this code to onCreated method, is the right place to implement it.
Also, I described how to implement it properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

let baseUrl = `livechat/visitors.chatHistory/room/${ rid}/visitor/${ visitorId }?searchText=${searchTerm}&count=${ ITEMS_COUNT }&offset=${ offset }`
const { resultArray } = await APIClient.v1.get(baseUrl);
if(resultArray.length==0){
return null;
}else{
return addTime(resultArray);
}
}

addTime = (array,value='false') => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this method.
As I described before, you have now the chatRoomHistoryItem template and you can implement this code there, as a helper method.

Then you will not need any loop, you will apply the method for each chatRoomHistoryItem. This is the right way to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now implementing this on chatRoomHistoryItem.js

if(value=='true'){
if(!isChanged){
array.shift();
isChanged = true;
}
}
for(var i=0; i<array.length;i++){
array[i].time = moment(array[i].ts).format('LT');
};
return array;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template name='customerChatHistoryMessages'>
{{#if isLoading}}
<h2 class='loding'>
{{_ "Loading..."}}
</h2>
{{else}}
<div class="chatHistory">
<div class='msgcount'>
<p><span>{{len}} messages</span></p>
</div>
<ul>
{{#each historyResult}}
{{#unless t}}
<li>
<div class="history-main">
<div class="history-img">
<img src="/avatar/{{u.username}}" >
</div>
<div class="history-detail-main">
<div class="detail-main-upper">
<h1>{{u.name}}</h1>
<p>{{time}}</p>
</div>
<div class="detail-main-lower">
<p>{{msg}}</p>
</div>
</div>
</div>
</li>
{{else}}
{{#if u.name}}
<div class="closed-div">
<p class='closed-div-p'><span>Conversation closed</span></p>
<div class="history-main">
<div class="history-img">
<div class='belldiv'>
<i class="icon-bell"></i>
</div>
</div>
<div class="history-detail-main">
<div class="detail-main-upper closed-h1">
<h1>Agent comment:</h1>
</div>
<div class="detail-main-lower closed-p">
<p>"{{msg}}".</p>
</div>
</div>
</div>
</div>
{{/if}}
{{/unless}}
{{/each}}
</ul>
</div>
{{/if}}
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Template } from 'meteor/templating';
import moment from 'moment';
import './customerChatHistoryMessages.html';
import { APIClient, t } from '../../../../../utils/client';
import { Session } from 'meteor/session';
import { ReactiveVar } from 'meteor/reactive-var';

Template.customerChatHistoryMessages.helpers({
historyResult() {
// will return all the messages in history room
return Template.instance().historyResult.get();
},
len() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper method is still there.

// will return length of total messages in room
let len = Template.instance().historyResult.get();
return len = len.length;
},
})
Template.customerChatHistoryMessages.onCreated(function() {
this.historyResult = new ReactiveVar([]);
this.history = new ReactiveVar([]);
var id = Session.get('FetchID');
var token = Session.get('FetchToken')
this.autorun(async () => {
const{ messages } = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${token}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to improve this kind of code, it's not according to the ESLint indentation.
I'm asking again: I can see a lot of warning on my code editor related to code stuff, like:

Screen Shot 2020-04-27 at 13 44 05

Suggested change
const{ messages } = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${token}`);
const { messages } = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${token}`);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed all type of these errors

// will return pervious chats list
this.history.set(messages);
let allMessages = addTIME(this.history.get());
var header = document.getElementsByClassName('contextual-bar__header-title');
var day,agentName;

if(allMessages.length !== 0){
var len = allMessages.length-1;
agentName = allMessages[len].u.username;
day = moment(allMessages[len].ts).format('dddd');
}
if(header[0]){
header[0].innerText= `${agentName}, closed at ${day}`
header[0].className = 'Contextualheading';
}
this.historyResult.set(allMessages);
})
})
addTIME = (array) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, you don't need this code here, we need to implement a helper method on the right template.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this i am implementing on the on-created method itself

let newArray = [];
for(var j=array.length-2; j>=1;j--){
array[j].time = moment(array[j].ts).format('LT');
newArray.push(array[j])
};
return newArray;

}


22 changes: 0 additions & 22 deletions app/livechat/client/views/app/tabbar/visitorHistory.html

This file was deleted.

Loading