Commit 2325998f18a4f6c2eee8f784bb7d669abed7917f
1 parent
a76e32db
Exists in
master
and in
111 other branches
Fix hub connection when user click in the SAMP button
Showing
1 changed file
with
35 additions
and
36 deletions
Show diff stats
js/app/views/SendToSampButtonUI.js
... | ... | @@ -41,27 +41,27 @@ Ext.define('amdaUI.SendToSampButtonUI', { |
41 | 41 | clientId : id, |
42 | 42 | handler : function () |
43 | 43 | { |
44 | - if (!me.testSAMPConnection()) | |
45 | - return; | |
46 | - if (me.onSendToSamp) | |
47 | - me.onSendToSamp.call(this,id,me.sendOpt); | |
44 | + me.testSAMPConnection(function () { | |
45 | + if (me.onSendToSamp) | |
46 | + me.onSendToSamp.call(this,id,me.sendOpt); | |
47 | + }); | |
48 | 48 | }, |
49 | 49 | icon : icon |
50 | 50 | }; |
51 | 51 | }, |
52 | 52 | |
53 | - testSAMPConnection : function() | |
53 | + testSAMPConnection : function(onConnected) | |
54 | 54 | { |
55 | - var interopModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id); | |
56 | - if (!interopModule) | |
57 | - return false; | |
58 | - if (!interopModule.sampConnected()) | |
59 | - { | |
60 | - interopModule.switchSampConnect(); | |
61 | - return false; | |
55 | + var me = this; | |
56 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) { | |
57 | + if (!module.sampConnected()) { | |
58 | + module.switchSampConnect(); | |
62 | 59 | } |
63 | - | |
64 | - return true; | |
60 | + else { | |
61 | + if (onConnected) | |
62 | + onConnected.call(); | |
63 | + } | |
64 | + }); | |
65 | 65 | }, |
66 | 66 | |
67 | 67 | updateMenu : function() |
... | ... | @@ -70,34 +70,33 @@ Ext.define('amdaUI.SendToSampButtonUI', { |
70 | 70 | |
71 | 71 | this.menu.removeAll(); |
72 | 72 | |
73 | - if (!this.testSAMPConnection()) | |
74 | - return false; | |
75 | - | |
76 | - var clients = []; | |
73 | + this.testSAMPConnection(function () { | |
74 | + var clients = []; | |
77 | 75 | |
78 | - var interopModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id); | |
79 | - if (!interopModule) | |
80 | - return false; | |
76 | + var interopModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id); | |
77 | + if (!interopModule) | |
78 | + return false; | |
81 | 79 | |
82 | - switch (this.type) | |
83 | - { | |
84 | - case 'fits' : | |
85 | - clients = interopModule.getFITSClients(); | |
86 | - break; | |
87 | - default : | |
88 | - clients = interopModule.getVOTableClients(); | |
89 | - } | |
80 | + switch (me.type) | |
81 | + { | |
82 | + case 'fits' : | |
83 | + clients = interopModule.getFITSClients(); | |
84 | + break; | |
85 | + default : | |
86 | + clients = interopModule.getVOTableClients(); | |
87 | + } | |
90 | 88 | |
91 | - Ext.each(clients,function(client) | |
89 | + Ext.each(clients,function(client) | |
92 | 90 | { |
93 | 91 | if (client['id'] != 'hub') |
94 | 92 | me.menu.add(me.getMenuItem(client['name'],client['id'],client['icon'])); |
95 | 93 | }); |
96 | - if (clients.length > 0) | |
97 | - { | |
98 | - me.menu.add('-'); | |
99 | - me.menu.add(me.getMenuItem('all clients','hub')); | |
100 | - } | |
94 | + if (clients.length > 0) | |
95 | + { | |
96 | + me.menu.add('-'); | |
97 | + me.menu.add(me.getMenuItem('all clients','hub')); | |
98 | + } | |
99 | + }); | |
101 | 100 | |
102 | 101 | return true; |
103 | 102 | }, |
... | ... | @@ -127,4 +126,4 @@ Ext.define('amdaUI.SendToSampButtonUI', { |
127 | 126 | |
128 | 127 | Ext.apply(this, newConfig); |
129 | 128 | } |
130 | -}); | |
131 | 129 | \ No newline at end of file |
130 | +}); | |
... | ... |