Skip to content

feat(panel-app): S8 — wiring do ReactionSummary no feed e no thread (… - #578

Open
BrunaDomingues wants to merge 1 commit into
he4rt:feat/timeline-reactionfrom
BrunaDomingues:feat/547-reaction-summary-wiring
Open

BrunaDomingues wants to merge 1 commit into
he4rt:feat/timeline-reactionfrom
BrunaDomingues:feat/547-reaction-summary-wiring

Conversation

@BrunaDomingues

Copy link
Copy Markdown
Contributor

feat(panel-app): S8 — wiring do ReactionSummary no feed e no thread (#547)

Pré-resolve counts/mine sem N+1, aposenta withCount('reactions') na timeline e reage a timeline.reaction-updated.

Contexto

A timeline web já tinha o enum, a action ReactWith, o query object ReactionSummary e o componente Livewire Reactions, mas o feed/thread ainda usavam o contador legado (withCount('reactions') / reactions_count) e não alimentavam o picker com o breakdown real.

Esta alteração pré-resolve counts/mine via ReactionSummary::forTimelines() no Feed, PostShow e ThreadReplies, passa o estado para <livewire:timeline-reactions> e escuta timeline.reaction-updated para re-render sem reload — sem N+1 e com custo constante de consultas de reação.

Alterações

  • Feed.php + feed.blade.php — batch de ReactionSummary após paginar; remove withCount('reactions'); passa counts/mine ao PostShow; escuta timeline.reaction-updated.
  • PostShow.php + post-show.blade.php — consome props do feed (ou consulta sozinho no thread); remove eager load/withCount de reactions; reações nas replies inline; escuta timeline.reaction-updated.
  • ThreadReplies.php + thread-replies.blade.php — batch de summaries por página de replies e picker em cada resposta; escuta timeline.reaction-updated.
  • ReactionSummaryWiringTest.php — breakdown feed/thread, custo constante (5 vs 25), ausência do contador legado, refresh após timeline.reaction-updated, summaries nas replies.

Plano de Testes

  • Executar make check
  • Executar make test
  • php artisan test --compact app-modules/panel-app/tests/Feature/Timeline/ReactionSummaryWiringTest.php
  • Feed e thread do mesmo post mostram o mesmo breakdown e o mesmo destaque da reação do usuário
  • Carregar o feed com 5 e com 25 posts reagidos mantém o mesmo nº de queries em activity_user_reactions
  • Nenhuma query do caminho da timeline usa withCount('reactions') / reactions_count
  • Reagir a um post atualiza o card sem reload da página (timeline.reaction-updated)
  • Replies no thread (e inline no post-show) exibem o picker com contagem/destaque corretos

Evidências

Sem impacto visual novo além do wiring: o seletor (S7) passa a receber estado real. Validação principal via testes Livewire (ReactionSummaryWiringTest.php).


Issues Relacionadas

Closes #547
Related to #539

…e4rt#547)

Pré-resolve counts/mine sem N+1, aposenta withCount('reactions') na timeline
e reage a timeline.reaction-updated.
@BrunaDomingues BrunaDomingues self-assigned this Oct 6, 2026

/** @var Collection<string, TimelineReactionSummary> $reactionSummaries */
$reactionSummaries = resolve(ReactionSummary::class)
->forTimelines($items->getCollection()->pluck('id'), auth()->id());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Troca isso por auth()->user()?->id vai resolver seu problema.

/** @var Collection<string, TimelineReactionSummary> $reactionSummaries */
$reactionSummaries = $idsToFetch === []
? Collection::make()
: resolve(ReactionSummary::class)->forTimelines($idsToFetch, auth()->id());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Troca isso por auth()->user()?->id vai resolver seu problema.

$rootReactionMine = $this->reactionMine;
} else {
$rootSummary = $reactionSummaries->get($this->timelineId);
$rootReactionCounts = $rootSummary?->counts ?? [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usar o $rootReactionCounts = $rootSummary->counts, pois o phpstan apontou que não precisa dessa validacao a mais pois o get acima sempre encontra algo.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants