@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.

Show only one "reload" popup, use 'alert' style, click to reload

Summary: Use the features from D2758.

Test Plan: Updated T1 with two browser windows pointing at it, verified reload appeared, only one reload, and it appeared with 'alert' style.

Reviewers: jungejason, vrana

Reviewed By: jungejason

CC: aran

Maniphest Tasks: T944

Differential Revision: https://secure.phabricator.com/D2781

+56 -32
+6 -5
src/__celerity_resource_map__.php
··· 779 779 ), 780 780 'javelin-behavior-aphlict-listen' => 781 781 array( 782 - 'uri' => '/res/4b1dc678/rsrc/js/application/aphlict/behavior-aphlict-listen.js', 782 + 'uri' => '/res/204f141a/rsrc/js/application/aphlict/behavior-aphlict-listen.js', 783 783 'type' => 'js', 784 784 'requires' => 785 785 array( 786 786 0 => 'javelin-behavior', 787 787 1 => 'javelin-aphlict', 788 - 2 => 'javelin-util', 789 - 3 => 'javelin-stratcom', 790 - 4 => 'javelin-behavior-aphlict-dropdown', 791 - 5 => 'phabricator-notification', 788 + 2 => 'javelin-stratcom', 789 + 3 => 'javelin-request', 790 + 4 => 'javelin-uri', 791 + 5 => 'javelin-dom', 792 + 6 => 'phabricator-notification', 792 793 ), 793 794 'disk' => '/rsrc/js/application/aphlict/behavior-aphlict-listen.js', 794 795 ),
+1 -2
src/view/page/PhabricatorStandardPageView.php
··· 404 404 'id' => $aphlict_object_id, 405 405 'server' => $client_uri->getDomain(), 406 406 'port' => $client_uri->getPort(), 407 - 'pageObjects' => $this->pageObjects, 407 + 'pageObjects' => array_fill_keys($this->pageObjects, true), 408 408 )); 409 409 410 410 Javelin::initBehavior('aphlict-dropdown', array()); 411 - 412 411 413 412 $notification_count = id(new PhabricatorFeedStoryNotification()) 414 413 ->countUnread($user);
+49 -25
webroot/rsrc/js/application/aphlict/behavior-aphlict-listen.js
··· 2 2 * @provides javelin-behavior-aphlict-listen 3 3 * @requires javelin-behavior 4 4 * javelin-aphlict 5 - * javelin-util 6 5 * javelin-stratcom 7 - * javelin-behavior-aphlict-dropdown 6 + * javelin-request 7 + * javelin-uri 8 + * javelin-dom 8 9 * phabricator-notification 9 10 */ 10 11 11 12 JX.behavior('aphlict-listen', function(config) { 13 + 14 + var showing_reload = false; 15 + 12 16 function onready() { 17 + var client = new JX.Aphlict(config.id, config.server, config.port) 18 + .setHandler(onaphlictmessage) 19 + .start(); 20 + } 13 21 14 - var client = new JX.Aphlict(config.id, config.server, config.port) 15 - .setHandler(function(type, message) { 16 - if (message) { 17 - if (type == 'receive') { 18 - var request = new JX.Request('/notification/individual/', 19 - function(response) { 20 - if (response.pertinent) { 21 - if (config.pageObjects.indexOf(response.primaryObjectPHID) 22 - > -1) { 23 - var notification = new JX.Notification() 24 - .setContent('Page updated. Please refresh.') 25 - .setDuration(0) // never timeout 26 - .show(); 27 - } 28 22 29 - JX.Stratcom.invoke('notification-panel-update', null, {}); 30 - } 31 - }); 32 - request.addData({ "key": message.key }); 33 - request.send(); 34 - } 35 - } 36 - }) 37 - .start(); 23 + // Respond to a notification from the Aphlict notification server. We send 24 + // a request to Phabricator to get notification details. 25 + function onaphlictmessage(type, message) { 26 + if (!message) { 27 + return; 28 + } 29 + 30 + if (type != 'receive') { 31 + return; 32 + } 33 + 34 + var request = new JX.Request('/notification/individual/', onnotification) 35 + .addData({key: message.key}) 36 + .send(); 37 + } 38 + 39 + 40 + // Respond to a response from Phabricator about a specific notification. 41 + function onnotification(response) { 42 + if (!response.pertinent) { 43 + return; 44 + } 45 + 46 + JX.Stratcom.invoke('notification-panel-update', null, {}); 47 + 48 + // If the notification affected an object on this page, show a 49 + // permanent reload notification if we aren't already. 50 + 51 + if ((response.primaryObjectPHID in config.pageObjects) && 52 + !showing_reload) { 53 + var reload = new JX.Notification() 54 + .setContent('Page updated, click to reload.') 55 + .setClassName('jx-notification-alert') 56 + .setDuration(0); 57 + reload.listen('activate', function(e) { JX.$U().go(); }) 58 + reload.show(); 59 + 60 + showing_reload = true; 61 + } 38 62 } 39 63 40 64