Fix updating anime status when certain fields are empty
All checks were successful
timw4mail/HummingBirdAnimeClient/pipeline/pr-master This commit looks good

This commit is contained in:
Timothy Warren 2020-10-07 15:30:42 -04:00
parent 24d6eaf0da
commit 238a423806
2 changed files with 16 additions and 5 deletions

View File

@ -32,7 +32,7 @@
<td>
<select name="watching_status" id="watching_status">
<?php foreach($statuses as $status_key => $status_title): ?>
<option <?php if($item['watching_status'] === $status_key): ?>selected="selected"<?php endif ?>
<option <?php if(strtolower($item['watching_status']) === $status_key): ?>selected="selected"<?php endif ?>
value="<?= $status_key ?>"><?= $status_title ?></option>
<?php endforeach ?>
</select>

View File

@ -143,16 +143,27 @@ final class ListItem extends AbstractListItem {
*/
public function update(string $id, FormItemData $data): Request
{
return $this->requestBuilder->mutateRequest('UpdateLibraryItem', [
// Data to always send
$updateData = [
'id' => $id,
'notes' => $data['notes'],
'private' => (bool)$data['private'],
'progress' => (int)$data['progress'],
'ratingTwenty' => (int)$data['ratingTwenty'],
'reconsumeCount' => (int)$data['reconsumeCount'],
'reconsuming' => (bool)$data['reconsuming'],
'status' => strtoupper($data['status']),
]);
];
// Only send these variables if they have a value
if ($data['progress'] !== NULL)
{
$updateData['progress'] = (int)$data['progress'];
}
if ($data['ratingTwenty'] !== NULL)
{
$updateData['ratingTwenty'] = (int)$data['ratingTwenty'];
}
return $this->requestBuilder->mutateRequest('UpdateLibraryItem', $updateData);
}
/**