Skip to content

Commit

Permalink
adddded .off() and changed rpc logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Enigma228322 committed Aug 23, 2019
1 parent 943650d commit 2e50f36
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions pos_chat/static/src/js/chat_button.js
Expand Up @@ -24,17 +24,8 @@ odoo.define('pos_chat_button', function (require){
self = this;
this.gui.show_screen('custom_screen');

if(!CheckUserExists(session.uid))
{
AddNewUser({
name : session.name,
uid : session.uid
});
}
Disconnected = false;

ShowUsers();

Refresh(self);
}
});
Expand All @@ -48,7 +39,7 @@ odoo.define('pos_chat_button', function (require){
args: ['', 'Connect',
session.uid]
});
window.setTimeout(Refresh, 2000, self);
window.setTimeout(Refresh,1500, self)
}

var PosModelSuper = models.PosModel;
Expand All @@ -66,8 +57,6 @@ odoo.define('pos_chat_button', function (require){

var self = this;

if(session.uid == data.uid) return;

if(data.command == 'Connect')
{
if(!CheckUserExists(data.uid))
Expand All @@ -87,7 +76,7 @@ odoo.define('pos_chat_button', function (require){
var self = this;
this._super();

this.$('.back').click(function () {
this.$('.back').off().click(function () {
self.gui.show_screen('products');

self._rpc({
Expand All @@ -98,11 +87,11 @@ odoo.define('pos_chat_button', function (require){
Disconnected = true;
});

this.$('.next').click(function () {
this.$('.next').off().click(function () {
TakeNewMessage()
});

this.$("#text-line").keyup(function(event){
this.$("#text-line").off().keyup(function(event){

if(event.keyCode == 13){
TakeNewMessage()
Expand Down Expand Up @@ -183,16 +172,6 @@ odoo.define('pos_chat_button', function (require){
var w = action_window.offsetWidth;
var h = action_window.offsetHeight;

if(chat_users.length == 1)
{
avatar.style.setProperty('position', 'absolute');
avatar.style.setProperty('left', w/2 - (avatar.offsetWidth / 2) + 'px');
avatar.style.setProperty('top', -avatar.offsetHeight + 'px');
avatar.style.setProperty('transform','translate3d(0px,'+h/2+'px,0px)');
avatar.style.setProperty('transition','transform 1s ease-in-out');
return;
}

var x = Math.trunc(radius*Math.cos(angle));
var y = Math.trunc(radius*Math.sin(angle));

Expand All @@ -209,10 +188,6 @@ odoo.define('pos_chat_button', function (require){

var newMessage = document.getElementById('text-line');

var length = Push_new_message(i, session.uid, newMessage.value);

showMessage(session.uid);

self._rpc({
model: "pos.chat",
method: "send_field_updates",
Expand Down Expand Up @@ -288,6 +263,7 @@ odoo.define('pos_chat_button', function (require){
{
if(chat_users[i].uid == uid) return i;
}
alert("Oh shit, here we go again");
return -1;
}

Expand Down

0 comments on commit 2e50f36

Please sign in to comment.