Skip to content

Commit 4486c18

Browse files
authored
Merge pull request #2751 from uProxy/jab-workarounds-all-the-way-down
workaround for #2659, caused by #2743
2 parents 8d12320 + ec508e6 commit 4486c18

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

src/cca/app/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<script src='../bower/webcomponentsjs/webcomponents.min.js'></script>
1212

1313
<script src='scripts/context.static.js'></script>
14+
<script src='scripts/workarounds.js'></script>
1415

1516
<!-- The vulcanized code will be loaded asynchronously by context.static.js -->
1617
<!-- <link rel='import' href='polymer/vulcanized.html'> -->
@@ -44,7 +45,7 @@
4445
</head>
4546

4647
<body unresolved touch-action='auto'>
47-
<!-- uproxy-root will be loaded after polymer is loaded -->
48+
<!-- uproxy-root will be appended here after polymer is loaded (see src/cca/app/scripts/context.ts) -->
4849
<!-- <uproxy-root></uproxy-root> -->
4950
</body>
5051

src/cca/app/scripts/context.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,3 @@ chrome.runtime.getBackgroundPage((bgPage) => {
3838
};
3939
document.head.appendChild(link);
4040
});
41-
42-
// Force a repaint every 300 ms.
43-
// Extremely hacky workaround for https://crbug.com/612836
44-
setInterval(function() {
45-
window.top.dispatchEvent(new Event('resize'));
46-
}, 300);
47-

src/cca/app/scripts/workarounds.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// CCA-specific workarounds.
2+
3+
(function () {
4+
// Force a repaint every 300 ms.
5+
// Extremely hacky workaround for https://crbug.com/612836
6+
7+
let sendResize = true;
8+
9+
setInterval(function () {
10+
if (sendResize) {
11+
window.dispatchEvent(new Event('resize'));
12+
} else {
13+
console.debug('suppressed resize event');
14+
}
15+
}, 300);
16+
17+
// Workaround for janky inviteUserPanel transition,
18+
// which is caused by the workaround above.
19+
// https://github.com/uProxy/uproxy/issues/2659
20+
document.addEventListener('uproxy-root-ready', function () {
21+
// The 'uproxy-root-ready' event is dispatched in the `ready()` method of
22+
// the uproxy root object instantiated in src/generic_ui/polymer/root.ts.
23+
console.debug('got uproxy-root-ready');
24+
let inviteButton = document.querySelector('uproxy-root /deep/ #inviteButton');
25+
if (!inviteButton) {
26+
console.error('#inviteButton missing:', inviteButton);
27+
return;
28+
}
29+
inviteButton.addEventListener('tap', function () {
30+
sendResize = false;
31+
setTimeout(function () { sendResize = true; }, 2000);
32+
});
33+
});
34+
})();

src/generic_ui/polymer/root.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ <h3>{{ "SHARING_ENABLED_TITLE" | $$(model.globalSettings.language) }}</h3>
419419
</div>
420420
</div>
421421
<!-- Elements (like the paper fab) that determine position based on proxying/error statuses, must come after the status elements above. Otherwise the positioning will be incorrect. -->
422+
<!-- src/cca/app/polymer/workarounds.ts attaches an on-tap handler to
423+
this #inviteButton element to work around #2659 (see PR #2751).
424+
Make sure to keep the id etc. synced up if changing. -->
422425
<paper-fab id="inviteButton"
423426
mini src='../icons/plus_white.svg'
424427
on-tap='{{ fireOpenInviteUserPanel }}'

src/generic_ui/polymer/root.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ Polymer({
159159
this.$.browserElementContainer.appendChild(browserCustomElement);
160160
}
161161
this.setDirectionality();
162+
// Logic that depends on the uproxy-root element being ready
163+
// (as in src/cca/app/polymer/workarounds.ts)
164+
// can be scheduled appropriately by listening for this event:
165+
document.dispatchEvent(new Event('uproxy-root-ready'));
162166
},
163167
tabSelected: function(e :Event) {
164168
if (this.ui.isSharingDisabled &&

0 commit comments

Comments
 (0)