-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7096 from RocketChat/convert-livechat-to-js
Convert Livechat from Coffeescript to JavaScript
- Loading branch information
Showing
33 changed files
with
983 additions
and
652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
packages/rocketchat-livechat/app/client/lib/_visitor.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* globals Commands */ | ||
const msgStream = new Meteor.Streamer('room-messages'); | ||
|
||
this.visitor = new class { | ||
constructor() { | ||
this.token = new ReactiveVar(null); | ||
this.room = new ReactiveVar(null); | ||
this.roomToSubscribe = new ReactiveVar(null); | ||
this.roomSubscribed = null; | ||
} | ||
|
||
register() { | ||
if (!localStorage.getItem('visitorToken')) { | ||
localStorage.setItem('visitorToken', Random.id()); | ||
} | ||
|
||
this.token.set(localStorage.getItem('visitorToken')); | ||
} | ||
|
||
getToken() { | ||
return this.token.get(); | ||
} | ||
|
||
setRoom(rid) { | ||
this.room.set(rid); | ||
} | ||
|
||
getRoom(createOnEmpty = false) { | ||
let roomId = this.room.get(); | ||
if (!roomId && createOnEmpty) { | ||
roomId = Random.id(); | ||
this.room.set(roomId); | ||
} | ||
|
||
return roomId; | ||
} | ||
|
||
isSubscribed(roomId) { | ||
return this.roomSubscribed === roomId; | ||
} | ||
|
||
subscribeToRoom(roomId) { | ||
if (this.roomSubscribed && this.roomSubscribed === roomId) { | ||
return; | ||
} | ||
|
||
this.roomSubscribed = roomId; | ||
|
||
msgStream.on(roomId, (msg) => { | ||
if (msg.t === 'command') { | ||
Commands[msg.msg] && Commands[msg.msg](); | ||
} else if (msg.t !== 'livechat_video_call') { | ||
ChatMessage.upsert({ _id: msg._id }, msg); | ||
|
||
if (msg.t === 'livechat-close') { | ||
parentCall('callback', 'chat-ended'); | ||
} | ||
|
||
// notification sound | ||
if (Session.equals('sound', true) && msg.u._id !== Meteor.userId()) { | ||
$('#chatAudioNotification')[0].play(); | ||
} | ||
} | ||
}); | ||
} | ||
}; |
220 changes: 0 additions & 220 deletions
220
packages/rocketchat-livechat/app/client/lib/chatMessages.coffee
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.