-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
[NEW] Additional Livechat iFrame API's #10918
Changes from 10 commits
8be9ee2
46a3c81
5e3dcbb
c25e005
da07919
30bc7c3
fd64d4e
e098d94
72a68e1
4421fb5
f1180d0
de54388
6f4e5d1
15f0e48
09df51b
3f9457d
dec7caf
8f62e75
8017a4a
a776d01
5a05cd7
03cad51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ Template.messages.helpers({ | |
}; | ||
}, | ||
agentData() { | ||
const agent = Livechat.agent; | ||
const agent = Template.instance().agentData.get(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is the same case as |
||
if (!agent) { | ||
return null; | ||
} | ||
|
@@ -137,6 +137,12 @@ Template.messages.onCreated(function() { | |
this.atBottom = true; | ||
|
||
this.showOptions = new ReactiveVar(false); | ||
this.agentData = new ReactiveVar(null); | ||
|
||
this.autorun(() => { | ||
const agentData = Livechat.agent; | ||
this.agentData.set(agentData); | ||
}); | ||
|
||
this.updateMessageInputHeight = function(input) { | ||
// Inital height is 28. If the scrollHeight is greater than that( we have more text than area ), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* globals Commands */ | ||
/* globals Commands, Livechat */ | ||
const msgStream = new Meteor.Streamer('room-messages'); | ||
|
||
export default { | ||
|
@@ -18,6 +18,23 @@ export default { | |
this.token.set(localStorage.getItem('visitorToken')); | ||
}, | ||
|
||
reset() { | ||
this.id.set(null); | ||
this.token.set(null); | ||
this.room.set(null); | ||
this.data.set(null); | ||
this.roomToSubscribe.set(null); | ||
this.roomSubscribed = null; | ||
|
||
Livechat.room = null; | ||
Livechat.department = null; | ||
Livechat.agent = null; | ||
Livechat.guestName = null; | ||
Livechat.guestEmail = null; | ||
|
||
msgStream.unsubscribe('room-messages'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this does not have the desired effect. on my tests after changing the token using |
||
}, | ||
|
||
getId() { | ||
return this.id.get(); | ||
}, | ||
|
@@ -38,6 +55,59 @@ export default { | |
return this.token.get(); | ||
}, | ||
|
||
setToken(token) { | ||
if ((!token) || (token == this.token.get())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need to use this much parenthesis.. without them the code looks much clearer: if (!token || token === this.token.get()) { |
||
return; | ||
} | ||
|
||
this.reset(); | ||
|
||
localStorage.setItem('visitorToken', token); | ||
this.token.set(token); | ||
|
||
Meteor.call('livechat:loginByToken', token, (err, result) => { | ||
|
||
if (!result) { | ||
return; | ||
} | ||
|
||
if (result._id) { | ||
this.setId(result._id); | ||
return result._id; | ||
} | ||
}); | ||
}, | ||
|
||
setName(name) { | ||
Livechat.guestName = name; | ||
|
||
if (!this.getId()) { | ||
return; | ||
} | ||
|
||
const data = { | ||
token: this.getToken(), | ||
name | ||
}; | ||
|
||
Meteor.call('livechat:registerGuest', data); | ||
}, | ||
|
||
setEmail(email) { | ||
Livechat.guestEmail = email; | ||
|
||
if (!this.getId()) { | ||
return; | ||
} | ||
|
||
const data = { | ||
token: this.getToken(), | ||
}; | ||
|
||
Meteor.call('livechat:registerGuest', data); | ||
}, | ||
|
||
setRoom(rid) { | ||
this.room.set(rid); | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,8 @@ Meteor.methods({ | |
RocketChat.models.Messages.keepHistoryForToken(token); | ||
|
||
return { | ||
userId | ||
userId, | ||
token | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on pull request #10767 this method will return the whole visitor object, I think you can to the same here (it should avoid future conflicts) |
||
}; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change to
if (typeof data !== 'object') {
to help readability