@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Invisible Macro/Meme: STFU

Summary:
For more than 10 years it was possible to troll your coworkers with
infinite audio loops, by typing a macro/meme in a comment box,
previewing, and then writing something else. This was happening
since macros may become hidden but still loaded in the DOM and,
in that case, they may play forever, until the page is destroyed.

The annoying sounds were also continuing when enjoying a meme and then
clicking on a different link, since page loads are often done by ajax,
effectively causing invisible memes in the DOM playing rickroll forever.

After this patch, no more audio from invisible macro/meme, effectively
implementing the beloved "STFU" alghorithm.

https://en.wikipedia.org/wiki/STFU

Note: you may appreciate that the audio volume still decreases
if you scroll up/down distant from a meme.
So, sounds are not really that annoying. Not even audio loops!
If a particular macro is annoying, then scroll down, or file a
severe complaint to your favorite Phorge admin to de-activate
that audio.

This patch is designed after D26674, to be not destructive.

Additionally, done small refactor to avoid 'statics.items[ii].element',
which can be written as just 'item.element'.

Closes T16486
Closes T16451

Test Plan:
Preamble: always click somewhere in the page for all tests,
otherwise modern browser webs like Firefox will likely deny audio,
even if you scroll straight to a meme.

-----

Locally, create a weird image macro (http://phorge.localhost/macro/create/)
for example called "freebird" and upload the sound of an epic
mp3 file, like the solo of Free Bird by Lynyrd Skynyrd, which is
somehow long. Example mp3:

https://quicksounds.com/sound/23840/free-bird-solo

Now, do the tests:

Write 'freebird' in a comment in a preview. Enjoy audio.
Remove 'freebird' from the preview, enjoy NO AUDIO \o/

Write 'freebird' in a comment and save. Enjoy audio.
Click a different link (e.g. 'Edit Task'). enjoy NO AUDIO \o/

Check for regressions in normal workflows:

Write 'freebird' in a comment and save. Enjoy audio.
Scroll distant from the meme, enjoy decreasing volume.
Scroll nearby the meme, enjoy increasing volume.

If it's a loop, the audio continues.
If it's not a loop, the audio terminates after the first run.

Reviewers: aklapper, O1 Blessed Committers

Reviewed By: aklapper, O1 Blessed Committers

Subscribers: tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T16451, T16486

Differential Revision: https://we.phorge.it/D26722

+20 -10
+8 -8
resources/celerity/map.php
··· 400 400 'rsrc/js/core/TextAreaUtils.js' => 'f340a484', 401 401 'rsrc/js/core/Title.js' => '43bc9360', 402 402 'rsrc/js/core/ToolTip.js' => '83754533', 403 - 'rsrc/js/core/behavior-audio-source.js' => '3dc5ad43', 403 + 'rsrc/js/core/behavior-audio-source.js' => '6e815b50', 404 404 'rsrc/js/core/behavior-autofocus.js' => '65bb0011', 405 405 'rsrc/js/core/behavior-badge-view.js' => '92cdd7b6', 406 406 'rsrc/js/core/behavior-bulk-editor.js' => 'aa6d2308', ··· 524 524 'javelin-behavior-aphront-drag-and-drop-textarea' => '6bc7ccf7', 525 525 'javelin-behavior-aphront-form-disable-on-submit' => 'c60fb44a', 526 526 'javelin-behavior-aphront-more' => '506aa3f4', 527 - 'javelin-behavior-audio-source' => '3dc5ad43', 527 + 'javelin-behavior-audio-source' => '6e815b50', 528 528 'javelin-behavior-audit-preview' => 'b7b73831', 529 529 'javelin-behavior-badge-view' => '92cdd7b6', 530 530 'javelin-behavior-bulk-editor' => 'aa6d2308', ··· 1156 1156 'javelin-vector', 1157 1157 'javelin-stratcom', 1158 1158 ), 1159 - '3dc5ad43' => array( 1160 - 'javelin-behavior', 1161 - 'javelin-stratcom', 1162 - 'javelin-vector', 1163 - 'javelin-dom', 1164 - ), 1165 1159 '3eed1f2b' => array( 1166 1160 'javelin-behavior', 1167 1161 'javelin-stratcom', ··· 1471 1465 'javelin-reactornode', 1472 1466 'javelin-install', 1473 1467 'javelin-util', 1468 + ), 1469 + '6e815b50' => array( 1470 + 'javelin-behavior', 1471 + 'javelin-stratcom', 1472 + 'javelin-vector', 1473 + 'javelin-dom', 1474 1474 ), 1475 1475 70245195 => array( 1476 1476 'javelin-behavior',
+12 -2
webroot/rsrc/js/core/behavior-audio-source.js
··· 53 53 } 54 54 } 55 55 56 - var pos = JX.Vector.getPos(statics.items[ii].element); 57 - var dim = JX.Vector.getDim(statics.items[ii].element); 56 + // Macros may become invisible (no 'offsetParent') for multiple reasons: 57 + // maybe you were looking at a preview but then you changed the content; 58 + // or maybe you clicked a link and the page was refreshed thanks to ajax. 59 + // Invisible memes should generally STFU. 60 + if (!item.element.offsetParent) { 61 + item.audio.pause(); 62 + item.playing = false; 63 + continue; 64 + } 65 + 66 + var pos = JX.Vector.getPos(item.element); 67 + var dim = JX.Vector.getDim(item.element); 58 68 59 69 var item_mid = pos.y + (dim.y / 2); 60 70 var item_distance = Math.abs(item_mid - view_mid);