Skip to content

Commit 5b209b0

Browse files
committed
- Added cookie clearing for error action
- Updated packages
1 parent 8e97956 commit 5b209b0

File tree

7 files changed

+295
-205
lines changed

7 files changed

+295
-205
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Online chat based on web sockets and ratchet php
99
[![License](https://poser.pugx.org/joni-jones/yii2-wschat/license)](https://packagist.org/packages/joni-jones/yii2-wschat)
1010
[![Join the chat at https://gitter.im/joni-jones/yii2-wschat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/joni-jones/yii2-wschat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1111

12-
> Because `jquery-cookie` moved to new repo. Please use `dev-master` version instead `*` in composer file.
13-
1412
![Demo] (doc/demo.gif)
1513

1614
Installation

assets/js/chat-room.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Chat.Room.prototype.init = function() {
1818
//if user id is not set - need to generate it(used for non auth users chat)
1919
if (!self.options.currentUserId) {
2020
self.options.currentUserId = Helper.uid();
21-
$.cookie('chatUserId', self.options.currentUserId);
21+
Cookies.set('chatUserId', self.options.currentUserId);
2222
}
2323
self.conn = new WebSocket('ws' + (location.protocol === 'https:' ? 's' : '') + '://'
2424
+ self.options.url + ':' + self.options.port);
@@ -43,7 +43,7 @@ Chat.Room.prototype.init = function() {
4343
Chat.Room.prototype.initLang = function() {
4444
var lang = navigator.language || navigator.userLanguage;
4545
lang = lang.split('-');
46-
$.cookie('chatLang', lang[0], {expires: 1});
46+
Cookies.set('chatLang', lang[0], {expires: 1});
4747
};
4848
Chat.Room.prototype.addEventsHandlers = function() {
4949
var self = this;
@@ -123,6 +123,7 @@ Chat.Room.prototype.onMessage = function(e) {
123123
break;
124124
case 'error':
125125
Helper.Message.error(Helper.t(response.data.message));
126+
Cookies.remove('chatUserId');
126127
break;
127128
}
128129
} catch (e) {
@@ -173,4 +174,4 @@ Chat.Room.prototype.showNotification = function(user) {
173174
}, 5000);
174175
};
175176
});
176-
};
177+
};

assets/js/chat.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
};
1717
Helper.t = function(message) {
18-
var lang = $.cookie('chatLang') || 'en';
18+
var lang = Cookies.get('chatLang') || 'en';
1919
if (lang === 'en') {
2020
return message;
2121
}

assets/js/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $(document).ready(function() {
1010
roomListView.render();
1111

1212
//create chat after rooms loading
13-
currentUserId = currentUserId || $.cookie('chatUserId');
13+
currentUserId = currentUserId || Cookies.get('chatUserId');
1414
var chat = new Chat.Room({port: port, currentUserId: currentUserId});
1515
if (!currentUserId) {
1616
var addUserView = new Chat.Views.AddUserView();
@@ -24,4 +24,4 @@ $(document).ready(function() {
2424
}
2525
var chatView = new Chat.Views.ChatView();
2626
var userListView = new Chat.Views.UserListView({collection: chat.users});
27-
});
27+
});

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"bower-asset/jquery": "2.*",
2020
"bower-asset/underscore": "1.8.3",
2121
"bower-asset/backbone": "1.2.*",
22-
"bower-asset/js-cookie": "1.5.*",
23-
"bower-asset/pnotify": "2.0.1",
22+
"bower-asset/js-cookie": "2.1.*",
23+
"bower-asset/pnotify": "2.0.*",
2424
"bower-asset/fontawesome": "4.*"
2525
},
2626
"require-dev": {

0 commit comments

Comments
 (0)