Do you wish to register an account?
Browse Source

Fix updating anime status when certain fields are empty

pull/32/head
Timothy Warren 3 months ago
parent
commit
238a423806
2 changed files with 16 additions and 5 deletions
  1. +1
    -1
      app/views/anime/edit.php
  2. +15
    -4
      src/AnimeClient/API/Kitsu/ListItem.php

+ 1
- 1
app/views/anime/edit.php 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>

+ 15
- 4
src/AnimeClient/API/Kitsu/ListItem.php 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);
}
/**

Loading…
Cancel
Save