diff options
Diffstat (limited to 'Digitigrade/Model/Note.php')
| -rw-r--r-- | Digitigrade/Model/Note.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Digitigrade/Model/Note.php b/Digitigrade/Model/Note.php index 0164e7d..a4df99d 100644 --- a/Digitigrade/Model/Note.php +++ b/Digitigrade/Model/Note.php @@ -82,10 +82,14 @@ class Note extends PushableModel implements TimelineIncludeable, Notifyable { $this->mentions = $this->findMentions(); $this->attachments = NoteAttachment::findAllWhere('note_id = ?', [$this->id]); $this->extensions = $this->findExtensions(); + + // put attachments back in the right order + usort($this->attachments, fn($a, $b) => $a->index <=> $b->index); } protected function dehydrate() { $this->saveMentions(); + $this->saveAttachments(); $this->saveExtensions(); } @@ -130,6 +134,15 @@ class Note extends PushableModel implements TimelineIncludeable, Notifyable { } } + private function saveAttachments() { + $index = 0; + foreach ($this->attachments as $att) { + $att->index = $index++; + $att->setOwnerId($this->id); + $att->save(); + } + } + private function saveExtensions() { $pdo = Db::getInstance()->getPdo(); foreach ($this->extensions as $uri => $obj) { |
