Skip to content

Commit c1d601e

Browse files
committed
Fix sync deletion bug
1 parent 060e27f commit c1d601e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Actions/SyncNotesAction.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ private function syncEntry(Syncable $syncable, BearNote $bearNote): ?SyncResult
3939
$entry = $this->findEntryFor($bearNote, $syncable->statamicCollection);
4040
$isNew = is_null($entry);
4141
$author = User::findByEmail($authorEmail = config('bearhub.author-email')) ?? User::current();
42+
$isTrashed = $bearNote->trashed && is_null($entry);
43+
$shouldUpdate = $isNew || $bearNote->hasContentOrStateChanges($entry->{BearEntryField::NoteChecksum});
4244

43-
if (!$isNew && !$bearNote->hasContentOrStateChanges($entry->{BearEntryField::NoteChecksum})) {
45+
if (!$shouldUpdate || $isTrashed) {
4446
return null;
4547
}
4648

4749
throw_unless($author, Exception::class, "BearHub: Did not find user with configured email {$authorEmail}. Be sure you have set the 'BEARHUB_AUTHOR_EMAIL' env variable.");
4850

49-
return $entry && $bearNote->trashed
51+
return $bearNote->trashed
5052
? $this->deleteEntry($entry)
5153
: $this->saveEntry($isNew, $syncable, $entry ?? Entry::make(), $bearNote, $author);
5254
}

0 commit comments

Comments
 (0)