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

master
Skylar Ittner 5 years ago
parent d4bcd56b90
commit e471355637

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

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

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

Loading…
Cancel
Save