Skip to content

Commit 78bfcc3

Browse files
committed
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
1 parent b467e58 commit 78bfcc3

File tree

8 files changed

+102
-30
lines changed

8 files changed

+102
-30
lines changed

resources/celerity/map.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
'rsrc/css/application/conpherence/durable-column.css' => 'f0c208ac',
4848
'rsrc/css/application/conpherence/menu.css' => 'f389e048',
4949
'rsrc/css/application/conpherence/message-pane.css' => 'e44b667b',
50-
'rsrc/css/application/conpherence/notification.css' => '04a6e10a',
50+
'rsrc/css/application/conpherence/notification.css' => '72178795',
5151
'rsrc/css/application/conpherence/update.css' => '1099a660',
5252
'rsrc/css/application/conpherence/widget-pane.css' => 'a9082fd0',
5353
'rsrc/css/application/contentsource/content-source-view.css' => '4b8b05d4',
@@ -518,7 +518,7 @@
518518
'conpherence-durable-column-view' => 'f0c208ac',
519519
'conpherence-menu-css' => 'f389e048',
520520
'conpherence-message-pane-css' => 'e44b667b',
521-
'conpherence-notification-css' => '04a6e10a',
521+
'conpherence-notification-css' => '72178795',
522522
'conpherence-thread-manager' => '0a5192c4',
523523
'conpherence-update-css' => '1099a660',
524524
'conpherence-widget-pane-css' => 'a9082fd0',

src/applications/conpherence/controller/ConpherenceColumnViewController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function handleRequest(AphrontRequest $request) {
1616
$latest_conpherences = id(new ConpherenceThreadQuery())
1717
->setViewer($user)
1818
->withPHIDs($conpherence_phids)
19+
->needTransactions(true)
1920
->needParticipantCache(true)
2021
->execute();
2122
$latest_conpherences = mpull($latest_conpherences, null, 'getPHID');

src/applications/conpherence/controller/ConpherenceListController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function handleRequest(AphrontRequest $request) {
100100
} else {
101101
$thread = ConpherenceThread::initializeNewThread($user);
102102
$thread->attachHandles(array());
103+
$thread->attachTransactions(array());
103104
$thread->makeEphemeral();
104105
$layout->setHeader(
105106
$this->buildHeaderPaneContent($thread, array()));
@@ -137,6 +138,7 @@ private function loadConpherenceThreadData($participation) {
137138
$conpherences = id(new ConpherenceThreadQuery())
138139
->setViewer($user)
139140
->withPHIDs($conpherence_phids)
141+
->needTransactions(true)
140142
->needParticipantCache(true)
141143
->execute();
142144

src/applications/conpherence/controller/ConpherenceNotificationPanelController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public function handleRequest(AphrontRequest $request) {
1717
$conpherences = id(new ConpherenceThreadQuery())
1818
->setViewer($user)
1919
->withPHIDs(array_keys($participant_data))
20+
->needTransactions(true)
2021
->needParticipantCache(true)
2122
->execute();
2223
}

src/applications/conpherence/controller/ConpherenceUpdateController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,16 +380,14 @@ private function loadAndRenderUpdates(
380380
$need_widget_data = false;
381381
$need_transactions = false;
382382
$need_participant_cache = true;
383+
$need_transactions = true;
383384
switch ($action) {
384385
case ConpherenceUpdateActions::METADATA:
385-
$need_transactions = true;
386386
break;
387387
case ConpherenceUpdateActions::LOAD:
388-
$need_transactions = true;
389388
break;
390389
case ConpherenceUpdateActions::MESSAGE:
391390
case ConpherenceUpdateActions::ADD_PERSON:
392-
$need_transactions = true;
393391
$need_widget_data = true;
394392
break;
395393
case ConpherenceUpdateActions::REMOVE_PERSON:

src/applications/conpherence/query/ConpherenceThreadSearchEngine.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function buildSavedQueryFromRequest(AphrontRequest $request) {
2727

2828
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
2929
$query = id(new ConpherenceThreadQuery())
30+
->needTransactions(true)
3031
->needParticipantCache(true);
3132

3233
$participant_phids = $saved->getParameter('participantPHIDs', array());

src/applications/conpherence/storage/ConpherenceThread.php

Lines changed: 89 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,12 @@ public function attachTransactions(array $transactions) {
124124
$this->transactions = $transactions;
125125
return $this;
126126
}
127-
public function getTransactions() {
127+
public function getTransactions($assert_attached = true) {
128128
return $this->assertAttached($this->transactions);
129129
}
130+
public function hasAttachedTransactions() {
131+
return $this->transactions !== self::ATTACHABLE;
132+
}
130133

131134
public function getTransactionsFrom($begin = 0, $amount = null) {
132135
$length = count($this->transactions);
@@ -154,13 +157,32 @@ public function getWidgetData() {
154157
}
155158

156159
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+
157179
$recent_phids = $this->getRecentParticipantPHIDs();
158180
$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....
162183
$lucky_phid = null;
163184
$lucky_index = null;
185+
$recent_title = null;
164186
foreach ($recent_phids as $index => $phid) {
165187
if ($phid == $user->getPHID()) {
166188
continue;
@@ -172,39 +194,82 @@ public function getDisplayData(PhabricatorUser $user) {
172194

173195
if ($lucky_phid) {
174196
$lucky_handle = $handles[$lucky_phid];
175-
// this will be just the user talking to themselves. weirdos.
176197
} else {
198+
// This will be just the user talking to themselves. Weirdo.
177199
$lucky_handle = reset($handles);
178200
}
179201

180-
$title = $js_title = $this->getTitle();
181202
$img_src = null;
182203
if ($lucky_handle) {
183204
$img_src = $lucky_handle->getImageURI();
184205
}
185206

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;
192226
}
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;
200249
}
201250
}
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+
}
205261
}
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;
208273
}
209274

210275
$user_participation = $this->getParticipantIfExists($user->getPHID());

webroot/rsrc/css/application/conpherence/notification.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
font-weight: bold;
3939
font-size: 13px;
4040
color: {$darkgreytext};
41-
width: 280px;
41+
width: 314px;
4242
text-overflow: ellipsis;
4343
white-space: nowrap;
4444
overflow: hidden;
@@ -51,6 +51,10 @@
5151
font-size: 11px;
5252
margin-top: 2px;
5353
margin-left: 46px;
54+
width: 314px;
55+
text-overflow: ellipsis;
56+
white-space: nowrap;
57+
overflow: hidden;
5458
}
5559

5660
.phabricator-notification .conpherence-menu-item-view

0 commit comments

Comments
 (0)