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

Convert Livechat from Coffeescript to JavaScript #7096

Merged
merged 2 commits into from
May 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 packages/rocketchat-lib/server/functions/sendMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RocketChat.sendMessage = function(user, message, room, upsert = false) {
message.msg = '';
}
message.rid = room._id;
if (room.usernames || room.usernames.length === 0) {
if (!room.usernames || room.usernames.length === 0) {
const updated_room = RocketChat.models.Rooms.findOneById(room._id);
if (updated_room != null) {
room = updated_room;
Expand Down
1 change: 0 additions & 1 deletion packages/rocketchat-livechat/app/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ underscore@1.0.10
jquery@1.11.10
random@1.0.10
ejson@1.0.13
coffeescript
rocketchat:streamer
kadira:flow-router
kadira:blaze-layout
Expand Down
57 changes: 0 additions & 57 deletions packages/rocketchat-livechat/app/client/lib/_visitor.coffee

This file was deleted.

66 changes: 66 additions & 0 deletions packages/rocketchat-livechat/app/client/lib/_visitor.js
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 packages/rocketchat-livechat/app/client/lib/chatMessages.coffee

This file was deleted.

Loading