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

Conpherence - change "A, B, C..." subtitle to "A: what most recent person said" when we can

Summary:
For the price of loading transactions more consistently, we get a better subtitle. We do this in all cases EXCEPT for when we're grabbing handles, because that makes the handles pretty heavy weight and I could even feel the perf hit on my development machine and we don't use subtitle there anyway. We may want to cache the latest message on the conpherence thread object to improve performance here as well as consider falling back to "A, B, C..." more often. Code is written such that no transactions means an automagical fallback.

Fixes T7795. (Technically, there's still a note about handle code conversion work on T7795 but we'll get that generally later.)

Test Plan:
played around with conpherence in both views and things seemed to work nicely.
made sure to try the original repro in T7795 and couldn't get that to go either
posted a long comment and verified that the CSS / string truncation both make it display nicely. Note that without the CSS the chosen glyph value can be too high to fit nicely at times.

Reviewers: chad, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7795

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

+102 -30
+2 -2
resources/celerity/map.php
··· 47 47 'rsrc/css/application/conpherence/durable-column.css' => 'f0c208ac', 48 48 'rsrc/css/application/conpherence/menu.css' => 'f389e048', 49 49 'rsrc/css/application/conpherence/message-pane.css' => 'e44b667b', 50 - 'rsrc/css/application/conpherence/notification.css' => '04a6e10a', 50 + 'rsrc/css/application/conpherence/notification.css' => '72178795', 51 51 'rsrc/css/application/conpherence/update.css' => '1099a660', 52 52 'rsrc/css/application/conpherence/widget-pane.css' => 'a9082fd0', 53 53 'rsrc/css/application/contentsource/content-source-view.css' => '4b8b05d4', ··· 518 518 'conpherence-durable-column-view' => 'f0c208ac', 519 519 'conpherence-menu-css' => 'f389e048', 520 520 'conpherence-message-pane-css' => 'e44b667b', 521 - 'conpherence-notification-css' => '04a6e10a', 521 + 'conpherence-notification-css' => '72178795', 522 522 'conpherence-thread-manager' => '0a5192c4', 523 523 'conpherence-update-css' => '1099a660', 524 524 'conpherence-widget-pane-css' => 'a9082fd0',
+1
src/applications/conpherence/controller/ConpherenceColumnViewController.php
··· 16 16 $latest_conpherences = id(new ConpherenceThreadQuery()) 17 17 ->setViewer($user) 18 18 ->withPHIDs($conpherence_phids) 19 + ->needTransactions(true) 19 20 ->needParticipantCache(true) 20 21 ->execute(); 21 22 $latest_conpherences = mpull($latest_conpherences, null, 'getPHID');
+2
src/applications/conpherence/controller/ConpherenceListController.php
··· 100 100 } else { 101 101 $thread = ConpherenceThread::initializeNewThread($user); 102 102 $thread->attachHandles(array()); 103 + $thread->attachTransactions(array()); 103 104 $thread->makeEphemeral(); 104 105 $layout->setHeader( 105 106 $this->buildHeaderPaneContent($thread, array())); ··· 137 138 $conpherences = id(new ConpherenceThreadQuery()) 138 139 ->setViewer($user) 139 140 ->withPHIDs($conpherence_phids) 141 + ->needTransactions(true) 140 142 ->needParticipantCache(true) 141 143 ->execute(); 142 144
+1
src/applications/conpherence/controller/ConpherenceNotificationPanelController.php
··· 17 17 $conpherences = id(new ConpherenceThreadQuery()) 18 18 ->setViewer($user) 19 19 ->withPHIDs(array_keys($participant_data)) 20 + ->needTransactions(true) 20 21 ->needParticipantCache(true) 21 22 ->execute(); 22 23 }
+1 -3
src/applications/conpherence/controller/ConpherenceUpdateController.php
··· 380 380 $need_widget_data = false; 381 381 $need_transactions = false; 382 382 $need_participant_cache = true; 383 + $need_transactions = true; 383 384 switch ($action) { 384 385 case ConpherenceUpdateActions::METADATA: 385 - $need_transactions = true; 386 386 break; 387 387 case ConpherenceUpdateActions::LOAD: 388 - $need_transactions = true; 389 388 break; 390 389 case ConpherenceUpdateActions::MESSAGE: 391 390 case ConpherenceUpdateActions::ADD_PERSON: 392 - $need_transactions = true; 393 391 $need_widget_data = true; 394 392 break; 395 393 case ConpherenceUpdateActions::REMOVE_PERSON:
+1
src/applications/conpherence/query/ConpherenceThreadSearchEngine.php
··· 27 27 28 28 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 29 29 $query = id(new ConpherenceThreadQuery()) 30 + ->needTransactions(true) 30 31 ->needParticipantCache(true); 31 32 32 33 $participant_phids = $saved->getParameter('participantPHIDs', array());
+89 -24
src/applications/conpherence/storage/ConpherenceThread.php
··· 124 124 $this->transactions = $transactions; 125 125 return $this; 126 126 } 127 - public function getTransactions() { 127 + public function getTransactions($assert_attached = true) { 128 128 return $this->assertAttached($this->transactions); 129 + } 130 + public function hasAttachedTransactions() { 131 + return $this->transactions !== self::ATTACHABLE; 129 132 } 130 133 131 134 public function getTransactionsFrom($begin = 0, $amount = null) { ··· 154 157 } 155 158 156 159 public function getDisplayData(PhabricatorUser $user) { 160 + if ($this->hasAttachedTransactions()) { 161 + $transactions = $this->getTransactions(); 162 + } else { 163 + $transactions = array(); 164 + } 165 + $set_title = $this->getTitle(); 166 + 167 + if ($set_title) { 168 + $title_mode = 'title'; 169 + } else { 170 + $title_mode = 'recent'; 171 + } 172 + 173 + if ($transactions) { 174 + $subtitle_mode = 'message'; 175 + } else { 176 + $subtitle_mode = 'recent'; 177 + } 178 + 157 179 $recent_phids = $this->getRecentParticipantPHIDs(); 158 180 $handles = $this->getHandles(); 159 - 160 - // luck has little to do with it really; most recent participant who isn't 161 - // the user.... 181 + // Luck has little to do with it really; most recent participant who 182 + // isn't the user.... 162 183 $lucky_phid = null; 163 184 $lucky_index = null; 185 + $recent_title = null; 164 186 foreach ($recent_phids as $index => $phid) { 165 187 if ($phid == $user->getPHID()) { 166 188 continue; ··· 172 194 173 195 if ($lucky_phid) { 174 196 $lucky_handle = $handles[$lucky_phid]; 175 - // this will be just the user talking to themselves. weirdos. 176 197 } else { 198 + // This will be just the user talking to themselves. Weirdo. 177 199 $lucky_handle = reset($handles); 178 200 } 179 201 180 - $title = $js_title = $this->getTitle(); 181 202 $img_src = null; 182 203 if ($lucky_handle) { 183 204 $img_src = $lucky_handle->getImageURI(); 184 205 } 185 206 186 - $count = 0; 187 - $final = false; 188 - $subtitle = null; 189 - foreach ($recent_phids as $phid) { 190 - if ($phid == $user->getPHID()) { 191 - continue; 207 + if ($title_mode == 'recent' || $subtitle_mode == 'recent') { 208 + $count = 0; 209 + $final = false; 210 + foreach ($recent_phids as $phid) { 211 + if ($phid == $user->getPHID()) { 212 + continue; 213 + } 214 + $handle = $handles[$phid]; 215 + if ($recent_title) { 216 + if ($final) { 217 + $recent_title .= '...'; 218 + break; 219 + } else { 220 + $recent_title .= ', '; 221 + } 222 + } 223 + $recent_title .= $handle->getName(); 224 + $count++; 225 + $final = $count == 3; 192 226 } 193 - $handle = $handles[$phid]; 194 - if ($subtitle) { 195 - if ($final) { 196 - $subtitle .= '...'; 197 - break; 198 - } else { 199 - $subtitle .= ', '; 227 + } 228 + 229 + switch ($title_mode) { 230 + case 'recent': 231 + $title = $recent_title; 232 + $js_title = $recent_title; 233 + break; 234 + case 'title': 235 + $title = $js_title = $this->getTitle(); 236 + break; 237 + } 238 + 239 + $message_title = null; 240 + if ($subtitle_mode == 'message') { 241 + $message_transaction = null; 242 + foreach ($transactions as $transaction) { 243 + switch ($transaction->getTransactionType()) { 244 + case PhabricatorTransactions::TYPE_COMMENT: 245 + $message_transaction = $transaction; 246 + break 2; 247 + default: 248 + break; 200 249 } 201 250 } 202 - $subtitle .= $handle->getName(); 203 - $count++; 204 - $final = $count == 3; 251 + if ($message_transaction) { 252 + $message_handle = $handles[$message_transaction->getAuthorPHID()]; 253 + $message_title = sprintf( 254 + '%s: %s', 255 + $message_handle->getName(), 256 + id(new PhutilUTF8StringTruncator()) 257 + ->setMaximumGlyphs(60) 258 + ->truncateString( 259 + $message_transaction->getComment()->getContent())); 260 + } 205 261 } 206 - if (!$title) { 207 - $title = $js_title = $subtitle; 262 + switch ($subtitle_mode) { 263 + case 'recent': 264 + $subtitle = $recent_title; 265 + break; 266 + case 'message': 267 + if ($message_title) { 268 + $subtitle = $message_title; 269 + } else { 270 + $subtitle = $recent_title; 271 + } 272 + break; 208 273 } 209 274 210 275 $user_participation = $this->getParticipantIfExists($user->getPHID());
+5 -1
webroot/rsrc/css/application/conpherence/notification.css
··· 38 38 font-weight: bold; 39 39 font-size: 13px; 40 40 color: {$darkgreytext}; 41 - width: 280px; 41 + width: 314px; 42 42 text-overflow: ellipsis; 43 43 white-space: nowrap; 44 44 overflow: hidden; ··· 51 51 font-size: 11px; 52 52 margin-top: 2px; 53 53 margin-left: 46px; 54 + width: 314px; 55 + text-overflow: ellipsis; 56 + white-space: nowrap; 57 + overflow: hidden; 54 58 } 55 59 56 60 .phabricator-notification .conpherence-menu-item-view