File tree Expand file tree Collapse file tree 4 files changed +16
-1
lines changed
Expand file tree Collapse file tree 4 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class="w-8 h-8 text-gray-400 dark:text-gray-500"
1616
1717 @foreach ($this -> comments as $comment )
1818 <livewire:commentions::comment
19- :key =" 'comment-' . $comment->getId ()"
19+ :key =" $comment->getContentHash ()"
2020 :comment =" $comment"
2121 :mentionables =" $mentionables"
2222 />
Original file line number Diff line number Diff line change @@ -173,6 +173,14 @@ public function getLabel(): ?string
173173 return null ;
174174 }
175175
176+ public function getContentHash (): string
177+ {
178+ return md5 (json_encode ([
179+ 'body ' => $ this ->body ,
180+ 'reactions ' => $ this ->reactions ->pluck ('id ' ),
181+ ]));
182+ }
183+
176184 protected static function newFactory ()
177185 {
178186 return CommentFactory::new ();
Original file line number Diff line number Diff line change @@ -21,4 +21,6 @@ public function getCreatedAt(): \DateTime|\Carbon\Carbon;
2121 public function getUpdatedAt (): \DateTime |\Carbon \Carbon ;
2222
2323 public function getLabel (): ?string ;
24+
25+ public function getContentHash (): string ;
2426}
Original file line number Diff line number Diff line change @@ -94,6 +94,11 @@ public function getLabel(): ?string
9494 return $ this ->label ;
9595 }
9696
97+ public function getContentHash (): string
98+ {
99+ return "comment- $ this ->id " ;
100+ }
101+
97102 public function toLivewire ()
98103 {
99104 return [
You can’t perform that action at this time.
0 commit comments