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

Fix weird subscribe+comment rendering

Summary:
Fixes T5146. When we're rendering a transaction group that includes a comment, we hide the "x added a comment" text, since it's implicit and obvious and cleans the UI up a little.

However, the way this works is really complicated and messy and created the T5146 issue after I made self-subscriptions have a lower priority than comments do.

Clean this code up so it makes a little more sense and gets this case right.

Test Plan: {F158270}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5146

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

+113 -116
+113 -116
src/view/phui/PHUITimelineEventView.php
··· 163 163 return $this; 164 164 } 165 165 166 - protected function renderEventTitle($is_first_event, $force_icon, $has_menu) { 167 - $title = $this->title; 168 - if (($title === null) && !$this->hasChildren()) { 169 - $title = ''; 166 + protected function shouldRenderEventTitle() { 167 + if ($this->title === null) { 168 + return false; 170 169 } 171 170 172 - if ($is_first_event) { 173 - $extra = array(); 174 - $is_first_extra = true; 175 - foreach ($this->getEventGroup() as $event) { 176 - $extra[] = $event->renderExtra($is_first_extra); 177 - $is_first_extra = false; 178 - } 179 - $extra = array_reverse($extra); 180 - $extra = array_mergev($extra); 181 - $extra = javelin_tag( 182 - 'span', 183 - array( 184 - 'class' => 'phui-timeline-extra', 185 - ), 186 - phutil_implode_html( 187 - javelin_tag( 188 - 'span', 189 - array( 190 - 'aural' => false, 191 - ), 192 - self::DELIMITER), 193 - $extra)); 194 - } else { 195 - $extra = null; 196 - } 171 + return true; 172 + } 197 173 198 - if ($title !== null || $extra) { 199 - $title_classes = array(); 200 - $title_classes[] = 'phui-timeline-title'; 174 + protected function renderEventTitle($force_icon, $has_menu, $extra) { 175 + $title = $this->title; 201 176 202 - $icon = null; 203 - if ($this->icon || $force_icon) { 204 - $title_classes[] = 'phui-timeline-title-with-icon'; 205 - } 177 + $title_classes = array(); 178 + $title_classes[] = 'phui-timeline-title'; 206 179 207 - if ($has_menu) { 208 - $title_classes[] = 'phui-timeline-title-with-menu'; 209 - } 180 + $icon = null; 181 + if ($this->icon || $force_icon) { 182 + $title_classes[] = 'phui-timeline-title-with-icon'; 183 + } 210 184 211 - if ($this->icon) { 212 - $fill_classes = array(); 213 - $fill_classes[] = 'phui-timeline-icon-fill'; 214 - if ($this->color) { 215 - $fill_classes[] = 'phui-timeline-icon-fill-'.$this->color; 216 - } 185 + if ($has_menu) { 186 + $title_classes[] = 'phui-timeline-title-with-menu'; 187 + } 217 188 218 - $icon = id(new PHUIIconView()) 219 - ->setIconFont($this->icon.' white') 220 - ->addClass('phui-timeline-icon'); 221 - 222 - $icon = phutil_tag( 223 - 'span', 224 - array( 225 - 'class' => implode(' ', $fill_classes), 226 - ), 227 - $icon); 189 + if ($this->icon) { 190 + $fill_classes = array(); 191 + $fill_classes[] = 'phui-timeline-icon-fill'; 192 + if ($this->color) { 193 + $fill_classes[] = 'phui-timeline-icon-fill-'.$this->color; 228 194 } 229 195 230 - $token = null; 231 - if ($this->token) { 232 - $token = id(new PHUIIconView()) 233 - ->addClass('phui-timeline-token') 234 - ->setSpriteSheet(PHUIIconView::SPRITE_TOKENS) 235 - ->setSpriteIcon($this->token); 236 - if ($this->tokenRemoved) { 237 - $token->addClass('strikethrough'); 238 - } 239 - } 196 + $icon = id(new PHUIIconView()) 197 + ->setIconFont($this->icon.' white') 198 + ->addClass('phui-timeline-icon'); 240 199 241 - $title = phutil_tag( 242 - 'div', 200 + $icon = phutil_tag( 201 + 'span', 243 202 array( 244 - 'class' => implode(' ', $title_classes), 203 + 'class' => implode(' ', $fill_classes), 245 204 ), 246 - array($icon, $token, $title, $extra)); 205 + $icon); 247 206 } 207 + 208 + $token = null; 209 + if ($this->token) { 210 + $token = id(new PHUIIconView()) 211 + ->addClass('phui-timeline-token') 212 + ->setSpriteSheet(PHUIIconView::SPRITE_TOKENS) 213 + ->setSpriteIcon($this->token); 214 + if ($this->tokenRemoved) { 215 + $token->addClass('strikethrough'); 216 + } 217 + } 218 + 219 + $title = phutil_tag( 220 + 'div', 221 + array( 222 + 'class' => implode(' ', $title_classes), 223 + ), 224 + array($icon, $token, $title, $extra)); 248 225 249 226 return $title; 250 227 } ··· 319 296 $has_menu = true; 320 297 } 321 298 299 + // Render "extra" information (timestamp, etc). 300 + $extra = $this->renderExtra($events); 301 + 322 302 $group_titles = array(); 323 303 $group_items = array(); 324 304 $group_children = array(); 325 - $is_first_event = true; 326 305 foreach ($events as $event) { 327 - $group_titles[] = $event->renderEventTitle( 328 - $is_first_event, 329 - $force_icon, 330 - $has_menu); 331 - $is_first_event = false; 306 + if ($event->shouldRenderEventTitle()) { 307 + $group_titles[] = $event->renderEventTitle( 308 + $force_icon, 309 + $has_menu, 310 + $extra); 311 + 312 + // Don't render this information more than once. 313 + $extra = null; 314 + } 315 + 332 316 if ($event->hasChildren()) { 333 317 $group_children[] = $event->renderChildren(); 334 318 } ··· 433 417 $content)); 434 418 } 435 419 436 - private function renderExtra($is_first_extra) { 420 + private function renderExtra(array $events) { 437 421 $extra = array(); 438 422 439 423 if ($this->getIsPreview()) { 440 424 $extra[] = pht('PREVIEW'); 441 425 } else { 442 - 443 - if ($this->getIsEdited()) { 444 - $extra[] = pht('Edited'); 426 + foreach ($events as $event) { 427 + if ($event->getIsEdited()) { 428 + $extra[] = pht('Edited'); 429 + break; 430 + } 445 431 } 446 432 447 - if ($is_first_extra) { 448 - $source = $this->getContentSource(); 449 - if ($source) { 450 - $extra[] = id(new PhabricatorContentSourceView()) 451 - ->setContentSource($source) 452 - ->setUser($this->getUser()) 453 - ->render(); 454 - } 433 + $source = $this->getContentSource(); 434 + if ($source) { 435 + $extra[] = id(new PhabricatorContentSourceView()) 436 + ->setContentSource($source) 437 + ->setUser($this->getUser()) 438 + ->render(); 439 + } 455 440 456 - $date_created = null; 457 - foreach ($this->getEventGroup() as $event) { 458 - if ($event->getDateCreated()) { 459 - if ($date_created === null) { 460 - $date_created = $event->getDateCreated(); 461 - } else { 462 - $date_created = min($event->getDateCreated(), $date_created); 463 - } 441 + $date_created = null; 442 + foreach ($events as $event) { 443 + if ($event->getDateCreated()) { 444 + if ($date_created === null) { 445 + $date_created = $event->getDateCreated(); 446 + } else { 447 + $date_created = min($event->getDateCreated(), $date_created); 464 448 } 465 449 } 450 + } 466 451 467 - if ($date_created) { 468 - $date = phabricator_datetime( 469 - $this->getDateCreated(), 470 - $this->getUser()); 471 - if ($this->anchor) { 472 - Javelin::initBehavior('phabricator-watch-anchor'); 452 + if ($date_created) { 453 + $date = phabricator_datetime( 454 + $date_created, 455 + $this->getUser()); 456 + if ($this->anchor) { 457 + Javelin::initBehavior('phabricator-watch-anchor'); 473 458 474 - $anchor = id(new PhabricatorAnchorView()) 475 - ->setAnchorName($this->anchor) 476 - ->render(); 459 + $anchor = id(new PhabricatorAnchorView()) 460 + ->setAnchorName($this->anchor) 461 + ->render(); 477 462 478 - $date = array( 479 - $anchor, 480 - phutil_tag( 481 - 'a', 482 - array( 483 - 'href' => '#'.$this->anchor, 484 - ), 485 - $date), 486 - ); 487 - } 488 - $extra[] = $date; 463 + $date = array( 464 + $anchor, 465 + phutil_tag( 466 + 'a', 467 + array( 468 + 'href' => '#'.$this->anchor, 469 + ), 470 + $date), 471 + ); 489 472 } 473 + $extra[] = $date; 490 474 } 475 + } 491 476 492 - } 477 + $extra = javelin_tag( 478 + 'span', 479 + array( 480 + 'class' => 'phui-timeline-extra', 481 + ), 482 + phutil_implode_html( 483 + javelin_tag( 484 + 'span', 485 + array( 486 + 'aural' => false, 487 + ), 488 + self::DELIMITER), 489 + $extra)); 493 490 494 491 return $extra; 495 492 }