Skip to content

Commit 2157c96

Browse files
committed
fix: address maintainer feedback on visual diff PR nextcloud#7212
- Move $usedRemoves assignment outside if-else block to reduce duplication - Merge remove/keep switch cases in renderWordLevelHtml as they have identical logic Addresses code review comments from @luka-nextcloud
1 parent ab145a4 commit 2157c96

2 files changed

Lines changed: 700 additions & 1 deletion

File tree

lib/Activity/DeckProvider.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use OCA\Deck\Db\Acl;
1111
use OCA\Deck\Service\CardService;
12+
use OCA\Deck\Service\DiffService;
1213
use OCP\Activity\IEvent;
1314
use OCP\Activity\IProvider;
1415
use OCP\Comments\IComment;
@@ -37,8 +38,10 @@ class DeckProvider implements IProvider {
3738
private $config;
3839
/** @var CardService */
3940
private $cardService;
41+
/** @var DiffService */
42+
private $diffService;
4043

41-
public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, IUserManager $userManager, ICommentsManager $commentsManager, IFactory $l10n, IConfig $config, $userId, CardService $cardService) {
44+
public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, IUserManager $userManager, ICommentsManager $commentsManager, IFactory $l10n, IConfig $config, $userId, CardService $cardService, DiffService $diffService) {
4245
$this->userId = $userId;
4346
$this->urlGenerator = $urlGenerator;
4447
$this->activityManager = $activityManager;
@@ -47,6 +50,7 @@ public function __construct(IURLGenerator $urlGenerator, ActivityManager $activi
4750
$this->l10nFactory = $l10n;
4851
$this->config = $config;
4952
$this->cardService = $cardService;
53+
$this->diffService = $diffService;
5054
}
5155

5256
/**
@@ -335,6 +339,20 @@ private function parseParamForDuedate($subjectParams, $params, IEvent $event) {
335339
* @return mixed
336340
*/
337341
private function parseParamForChanges($subjectParams, $params, $event) {
342+
// Handle card description changes with visual diff
343+
if ($event->getSubject() === ActivityManager::SUBJECT_CARD_UPDATE_DESCRIPTION &&
344+
array_key_exists('before', $subjectParams) && array_key_exists('after', $subjectParams)) {
345+
346+
$before = (string)($subjectParams['before'] ?? '');
347+
$after = (string)($subjectParams['after'] ?? '');
348+
349+
// Generate visual diff and set as parsed message
350+
$diffHtml = $this->diffService->generateDiff($before, $after);
351+
$event->setParsedMessage($diffHtml);
352+
353+
return $params;
354+
}
355+
338356
if (array_key_exists('diff', $subjectParams) && $subjectParams['diff'] && !empty($subjectParams['after'])) {
339357
// Don't add diff as message since we are limited to 255 chars here
340358
$event->setParsedMessage($subjectParams['after']);

0 commit comments

Comments
 (0)