Update note modified date when favorite status changes, fix API bug preventing notes from being unfavorited

This commit is contained in:
Skylar Ittner 2019-01-23 18:23:13 -07:00
parent d4bcd56b90
commit e471355637
3 changed files with 5 additions and 2 deletions

View File

@ -104,6 +104,7 @@ switch ($VARS['action']) {
die($Strings->get("invalid parameters"));
}
$note->setFavorite(!$note->getFavorite());
$note->setModified(date("Y-m-d H:i:s"));
$note->saveNote();
returnToSender("");
break;

View File

@ -15,12 +15,14 @@ try {
if (!$note->hasWriteAccess(getRequestUser())) {
sendJsonResp($Strings->get("You don't have permission to edit this note.", false), "ERROR");
}
if (empty($VARS['favorite'])) {
if (!isset($VARS['favorite'])) {
$note->setFavorite(!$note->getFavorite());
} else {
$note->setFavorite($VARS['favorite'] == true);
}
$note->setModified(date("Y-m-d H:i:s"));
$note->saveNote();
sendJsonResp($Strings->get("Note saved", false), "OK", ["note" => $note->toArray()]);

View File

@ -47,7 +47,7 @@ if (empty($VARS['modified'])) {
$note->setModified($VARS['modified']);
}
if (!empty($VARS['favorite'])) {
if (isset($VARS['favorite'])) {
$note->setFavorite($VARS['favorite'] == true);
}