Skip to content

Commit 1df87ef

Browse files
committed
fix hangouts message notifier and click handler, use new API setters
1 parent 7ac7d4b commit 1df87ef

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

sites/Hangouts/app.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
//$.readyForClickedNotifications = false; // the hangouts site takes some time to load...
2+
// https://webrtchacks.com/hangout-analysis-philipp-hancke/
23

34
var delegate = {}; // our delegate to receive events from the webview app
45

56
delegate.decideNavigationForClickedURL = function(url) { $.sysOpenURL(url); return true; }
67
delegate.decideNavigationForMIME = function(url) { return false; }
78
delegate.decideWindowOpenForURL = function(url) {
8-
if (~url.indexOf("https://plus.google.com/hangouts/_")) { //G+ hangouts a/v chat
9-
//$.sysOpenURL(url, "com.google.Chrome"); // use Hangouts Pepper WebRTC plugin
10-
$.newAppTabWithJS(url);
11-
$.switchToNextTab();
9+
$.conlog("JScore: catching window.open() " + url);
10+
if (~url.indexOf("https://plus.google.com/hangouts/_/")) { //G+ hangouts a/v chat
11+
$.sysOpenURL(url, "com.google.Chrome"); // use Hangouts Pepper WebRTC plugin
12+
//$.newAppTabWithJS(url);
13+
//$.switchToNextTab();
1214
return true;
1315
};
1416
//if url ^= https://talkgadget.google.com/u/0/talkgadget/_/frame
@@ -41,6 +43,7 @@ delegate.launchURL = function(url) { // $.sysOpenURL(/[sms|hangouts|tel]:.*/) ca
4143
};
4244
};
4345

46+
//addEventListener('receivedHangoutsMessage', function(e){...}, false); ??
4447
delegate.receivedHangoutsMessage = function(msg) {
4548
// receives events from JS in 1st AppTab
4649
// -> webkit.messageHandlers.receivedHangoutMessage.postMessage([from, replyTo, msg]);
@@ -51,12 +54,13 @@ delegate.receivedHangoutsMessage = function(msg) {
5154

5255
delegate.handleClickedNotification = function(from, url, msg) {
5356
$.conlog("JS: opening notification for: "+ [from, url, msg]);
54-
//$.sysOpenURL(url); //will end back up at launchURL
57+
$.sysOpenURL(url); //will end back up at launchURL
5558
return true;
5659
};
5760

5861
delegate.unhideApp = function(msg) { $.unhideApp(); };
5962

63+
//addEventListener('HangoutsRosterReady', function(e){...}, false); ??
6064
delegate.HangoutsRosterReady = function(msg) { // notifier.js will call this when roster div is created
6165
//$.readyForClickedNotifications = true;
6266
if ($.lastLaunchedURL != '') { //app was launched by an opened URL or a clicked notification - probably a [sms|tel]: link
@@ -66,7 +70,7 @@ delegate.HangoutsRosterReady = function(msg) { // notifier.js will call this whe
6670
};
6771

6872
delegate.AppFinishedLaunching = function() {
69-
$.toggleTransparency();
73+
$.isTransparent = true;
7074
$.registerURLScheme('sms');
7175
$.registerURLScheme('tel');
7276
$.registerURLScheme('hangouts');

sites/Hangouts/notifier.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ if (window.name == 'gtn-roster-iframe-id-b') {
9292
//if (mut.addedNodes.length > 0)
9393
if (roster = mut.target.querySelector('div[tabindex="-1"]')) {
9494
console.log("Found Hangouts chat roster, dispatching HangoutsRosterReady event");
95-
setTimeout(function(){
96-
window.dispatchEvent(new window.CustomEvent('HangoutsRosterReady',{'detail':{'roster': roster}}));
97-
}, 10000); //need a little lag so hangouts can load up the contacts
98-
window.rosterWatcher.unobserve(); // FIXME: use 'this'
95+
window.dispatchEvent(new window.CustomEvent('HangoutsRosterReady',{'detail':{'roster': roster}}));
96+
window.rosterWatcher.disconnect(); // FIXME: use 'this'
9997
break;
10098
}
10199
}
@@ -197,9 +195,11 @@ if (window.name == 'gtn-roster-iframe-id-b') {
197195
var rosterWatcher;
198196
window.addEventListener("HangoutsRosterReady", function(event) {
199197
console.log("Caught HangoutsRosterReady event, dispatching message watcher");
200-
webkit.messageHandlers.HangoutsRosterReady.postMessage([]); //callback JSCore to accept queued new message URLs
198+
window.rosterWatcher.disconnect();
199+
setTimeout(function(){
200+
webkit.messageHandlers.HangoutsRosterReady.postMessage([]); //callback JSCore to accept queued new message URLs
201+
}, 10000); //need a little lag so hangouts can finish populating contacts in the roster
201202
var chatWatcher = window.WatchForNewMessages(event.detail['roster']); //watch the whole roster
202-
rosterWatcher.disconnect();
203203
}, false);
204204
rosterWatcher = window.WatchForRoster();
205205

sites/Trello/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ delegate.handleClickedNotifcation = function(from, url, msg) { $.sysOpenURL(url)
4444

4545
delegate.AppFinishedLaunching = function() {
4646
$.registerURLScheme('trello');
47-
$.toggleTransparency();
47+
$.isTransparent = true;
4848

4949
if ($.lastLaunchedURL != '') {
5050
delegate.launchURL($.lastLaunchedURL);
@@ -54,6 +54,5 @@ delegate.AppFinishedLaunching = function() {
5454
'postinject':['dnd','styler','notifier'],
5555
'handlers':['TrelloNotification']
5656
});
57-
}
5857
}
5958
delegate; //return this to macpin

0 commit comments

Comments
 (0)