Simplify code

This commit is contained in:
Michael 2023-11-04 21:37:47 +00:00
parent 21cb18fb4b
commit 6de1676337

View file

@ -681,63 +681,56 @@ class Post
$emojis = []; $emojis = [];
foreach ($item['emojis'] as $index => $element) { foreach ($item['emojis'] as $index => $element) {
$key = $element['verb'];
$actors = implode(', ', $element['title']); $actors = implode(', ', $element['title']);
switch ($element['verb']) { switch ($element['verb']) {
case Activity::ANNOUNCE: case Activity::ANNOUNCE:
$title = DI::l10n()->t('Reshared by: %s', $actors); $title = DI::l10n()->t('Reshared by: %s', $actors);
$icon = ['fa' => 'fa-retweet', 'icon' => 'icon-retweet']; $icon = ['fa' => 'fa-retweet', 'icon' => 'icon-retweet'];
$verb = Activity::ANNOUNCE;
break; break;
case Activity::VIEW: case Activity::VIEW:
$title = DI::l10n()->t('Viewed by: %s', $actors); $title = DI::l10n()->t('Viewed by: %s', $actors);
$icon = ['fa' => 'fa-eye', 'icon' => 'icon-eye-open']; $icon = ['fa' => 'fa-eye', 'icon' => 'icon-eye-open'];
$verb = Activity::VIEW;
break; break;
case Activity::LIKE: case Activity::LIKE:
$title = DI::l10n()->t('Liked by: %s', $actors); $title = DI::l10n()->t('Liked by: %s', $actors);
$icon = ['fa' => 'fa-thumbs-up', 'icon' => 'icon-thumbs-up']; $icon = ['fa' => 'fa-thumbs-up', 'icon' => 'icon-thumbs-up'];
$verb = Activity::LIKE;
break; break;
case Activity::DISLIKE: case Activity::DISLIKE:
$title = DI::l10n()->t('Disliked by: %s', $actors); $title = DI::l10n()->t('Disliked by: %s', $actors);
$icon = ['fa' => 'fa-thumbs-down', 'icon' => 'icon-thumbs-down']; $icon = ['fa' => 'fa-thumbs-down', 'icon' => 'icon-thumbs-down'];
$verb = Activity::DISLIKE;
break; break;
case Activity::ATTEND: case Activity::ATTEND:
$title = DI::l10n()->t('Attended by: %s', $actors); $title = DI::l10n()->t('Attended by: %s', $actors);
$icon = ['fa' => 'fa-check', 'icon' => 'icon-ok']; $icon = ['fa' => 'fa-check', 'icon' => 'icon-ok'];
$verb = Activity::ATTEND;
break; break;
case Activity::ATTENDMAYBE: case Activity::ATTENDMAYBE:
$title = DI::l10n()->t('Maybe attended by: %s', $actors); $title = DI::l10n()->t('Maybe attended by: %s', $actors);
$icon = ['fa' => 'fa-question', 'icon' => 'icon-question']; $icon = ['fa' => 'fa-question', 'icon' => 'icon-question'];
$verb = Activity::ATTENDMAYBE;
break; break;
case Activity::ATTENDNO: case Activity::ATTENDNO:
$title = DI::l10n()->t('Not attended by: %s', $actors); $title = DI::l10n()->t('Not attended by: %s', $actors);
$icon = ['fa' => 'fa-times', 'icon' => 'icon-remove']; $icon = ['fa' => 'fa-times', 'icon' => 'icon-remove'];
$verb = Activity::ATTENDNO;
break; break;
case Activity::POST: case Activity::POST:
$title = DI::l10n()->t('Commented by: %s', $actors); $title = DI::l10n()->t('Commented by: %s', $actors);
$icon = ['fa' => 'fa-commenting', 'icon' => 'icon-remove']; $icon = ['fa' => 'fa-commenting', 'icon' => 'icon-commenting'];
$verb = Activity::POST;
break; break;
default: default:
$title = DI::l10n()->t('Reacted with %s by: %s', $element['emoji'], $actors); $title = DI::l10n()->t('Reacted with %s by: %s', $element['emoji'], $actors);
$icon = []; $icon = [];
$verb = $element['emoji']; $key = $element['emoji'];
break; break;
} }
$emojis[$verb] = ['emoji' => $element['emoji'], 'total' => $element['total'], 'title' => $title, 'icon' => $icon]; $emojis[$key] = ['emoji' => $element['emoji'], 'total' => $element['total'], 'title' => $title, 'icon' => $icon];
} }
return $emojis; return $emojis;