Browse Source

Make syncing slightly more robust

Timothy Warren 3 months ago
parent
commit
59403b9cb5

+ 1
- 1
app/views/collection/list-item.php View File

@@ -9,7 +9,7 @@
9 9
 		<a href="<?= $url->generate('anime.details', ['id' => $item['slug']]) ?>">
10 10
 			<?= $item['title'] ?>
11 11
 		</a>
12
-		<?= (!empty($item['alternate_title'])) ? " <br /><small> " . $item['alternate_title'] . "</small>" : "" ?>
12
+		<?= ! empty($item['alternate_title']) ? ' <br /><small> ' . $item['alternate_title'] . '</small>' : '' ?>
13 13
 	</td>
14 14
 	<td><?= $item['episode_count'] ?></td>
15 15
 	<td><?= $item['episode_length'] ?></td>

+ 18
- 0
public/css/dark-override.css View File

@@ -1,5 +1,6 @@
1 1
 a {
2 2
 	color: rgb(25, 120, 226);
3
+	text-shadow: var(--link-shadow);
3 4
 }
4 5
 
5 6
 a:hover {
@@ -55,6 +56,23 @@ input, select, textarea {
55 56
 	color: #111;
56 57
 }
57 58
 
59
+.message, .static-message {
60
+	text-shadow: var(--white-link-shadow);
61
+}
62
+
63
+.message.success, .static-message.success {
64
+	background: #1f8454;
65
+	border-color: #70dda9;
66
+}
67
+.message.error, .static-message.error {
68
+	border-color:#f3e6e6;
69
+	background: #924949;
70
+}
71
+.message.info, .static-message.info {
72
+	border-color: #FFFFCC;
73
+	background: #bfbe3a;
74
+}
75
+
58 76
 .invisible tr,
59 77
 .invisible td,
60 78
 .invisible th,

+ 1
- 1
public/css/dark.min.css View File

@@ -1 +1 @@
1
-a{color:#1978e2}a:hover{color:#9e34fd}body,legend,nav ul li a{background:#333;color:#eee}nav a:hover,nav li.selected a{border-color:#fff}header button{background:transparent}table{-webkit-box-shadow:none;box-shadow:none}td,th{border-color:#111}thead td,thead th{background:#333;color:#eee}tbody>tr:nth-child(2n){background:#555;color:#eee}tbody>tr:nth-child(odd){background:#333}footer,hr,legend{border-color:#ddd}small{color:#fff}input,select,textarea{color:#111}.invisible tbody>tr:nth-child(2n),.invisible tbody>tr:nth-child(odd),.invisible td,.invisible th,.invisible tr{background:transparent}#main-nav{border-bottom:.1rem solid #ddd}.tabs,.vertical-tabs{background:#333}.tabs>label,.vertical-tabs .tab label{background:#222;border:0;color:#eee}.vertical-tabs .tab label{width:100%}.tabs>label:hover,.vertical-tabs .tab>label:hover{background:#888}.tabs>label:active,.vertical-tabs .tab>label:active{background:#999}.tabs>[type=radio]:checked+label,.tabs>[type=radio]:checked+label+.content,.vertical-tabs [type=radio]:checked+label,.vertical-tabs [type=radio]:checked~.content{border:0;background:#666;color:#eee}.vertical-tabs{background:#222;border:1px solid #444}.vertical-tabs .tab{background:#666;border-bottom:1px solid #444}
1
+a{color:#1978e2;text-shadow:var(--link-shadow)}a:hover{color:#9e34fd}body,legend,nav ul li a{background:#333;color:#eee}nav a:hover,nav li.selected a{border-color:#fff}header button{background:transparent}table{-webkit-box-shadow:none;box-shadow:none}td,th{border-color:#111}thead td,thead th{background:#333;color:#eee}tbody>tr:nth-child(2n){background:#555;color:#eee}tbody>tr:nth-child(odd){background:#333}footer,hr,legend{border-color:#ddd}small{color:#fff}input,select,textarea{color:#111}.message,.static-message{text-shadow:var(--white-link-shadow)}.message.success,.static-message.success{background:#1f8454;border-color:#70dda9}.message.error,.static-message.error{border-color:#f3e6e6;background:#924949}.message.info,.static-message.info{border-color:#ffc;background:#bfbe3a}.invisible tbody>tr:nth-child(2n),.invisible tbody>tr:nth-child(odd),.invisible td,.invisible th,.invisible tr{background:transparent}#main-nav{border-bottom:.1rem solid #ddd}.tabs,.vertical-tabs{background:#333}.tabs>label,.vertical-tabs .tab label{background:#222;border:0;color:#eee}.vertical-tabs .tab label{width:100%}.tabs>label:hover,.vertical-tabs .tab>label:hover{background:#888}.tabs>label:active,.vertical-tabs .tab>label:active{background:#999}.tabs>[type=radio]:checked+label,.tabs>[type=radio]:checked+label+.content,.vertical-tabs [type=radio]:checked+label,.vertical-tabs [type=radio]:checked~.content{border:0;background:#666;color:#eee}.vertical-tabs{background:#222;border:1px solid #444}.vertical-tabs .tab{background:#666;border-bottom:1px solid #444}

+ 8
- 3
src/API/Anilist/Transformer/AnimeListTransformer.php View File

@@ -17,6 +17,7 @@
17 17
 namespace Aviat\AnimeClient\API\Anilist\Transformer;
18 18
 
19 19
 use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Anilist as AnilistStatus;
20
+use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Kitsu as KitsuStatus;
20 21
 use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
21 22
 use Aviat\AnimeClient\Types\{AnimeListItem, FormItem};
22 23
 
@@ -39,6 +40,8 @@ class AnimeListTransformer extends AbstractTransformer {
39 40
 	 */
40 41
 	public function untransform(array $item): FormItem
41 42
 	{
43
+		$reconsuming = $item['status'] === AnilistStatus::REPEATING;
44
+
42 45
 		return new FormItem([
43 46
 			'id' => $item['id'],
44 47
 			'mal_id' => $item['media']['idMal'],
@@ -46,10 +49,12 @@ class AnimeListTransformer extends AbstractTransformer {
46 49
 				'notes' => $item['notes'] ?? '',
47 50
 				'private' => $item['private'],
48 51
 				'progress' => $item['progress'],
49
-				'rating' => $item['score'],
52
+				'rating' => $item['score'] ?? NULL,
50 53
 				'reconsumeCount' => $item['repeat'],
51
-				'reconsuming' => $item['status'] === AnilistStatus::REPEATING,
52
-				'status' => AnimeWatchingStatus::ANILIST_TO_KITSU[$item['status']],
54
+				'reconsuming' => $reconsuming,
55
+				'status' => $reconsuming
56
+					? KitsuStatus::WATCHING
57
+					:AnimeWatchingStatus::ANILIST_TO_KITSU[$item['status']],
53 58
 				'updatedAt' => (new DateTime())
54 59
 					->setTimestamp($item['updatedAt'])
55 60
 					->format(DateTime::W3C)

+ 13
- 3
src/Command/SyncLists.php View File

@@ -268,7 +268,7 @@ final class SyncLists extends BaseCommand {
268 268
 				{
269 269
 					continue;
270 270
 				}
271
-				
271
+
272 272
 				if (array_key_exists($mappingId, $includes['mappings']))
273 273
 				{
274 274
 					$malId = $includes['mappings'][$mappingId]['externalId'];
@@ -510,12 +510,16 @@ final class SyncLists extends BaseCommand {
510 510
 		// Use the first set rating, otherwise use the newer rating
511 511
 		if ( ! $sameRating)
512 512
 		{
513
-			if ($kitsuItem['data']['rating'] !== 0 && $dateDiff === 1)
513
+			if (
514
+				$dateDiff === 1 &&
515
+				$kitsuItem['data']['rating'] !== 0 &&
516
+				$kitsuItem['data']['ratingTwenty'] !== 0
517
+			)
514 518
 			{
515 519
 				$update['data']['ratingTwenty'] = $kitsuItem['data']['ratingTwenty'];
516 520
 				$return['updateType'][] = 'anilist';
517 521
 			}
518
-			else if($dateDiff === -1)
522
+			else if($dateDiff === -1 && $anilistItem['data']['rating'] !== 0)
519 523
 			{
520 524
 				$update['data']['ratingTwenty'] = $anilistItem['data']['rating'] * 2;
521 525
 				$return['updateType'][] = 'kitsu';
@@ -552,6 +556,12 @@ final class SyncLists extends BaseCommand {
552 556
 			}
553 557
 		}
554 558
 
559
+		// No changes? Let's bail!
560
+		if (empty($return['updateType']))
561
+		{
562
+			return $return;
563
+		}
564
+
555 565
 		$return['meta'] = [
556 566
 			'kitsu' => $kitsuItem['data'],
557 567
 			'anilist' => $anilistItem['data'],

+ 1
- 1
src/Controller/AnimeCollection.php View File

@@ -137,7 +137,7 @@ final class AnimeCollection extends BaseController {
137 137
 	 * @throws \InvalidArgumentException
138 138
 	 * @return void
139 139
 	 */
140
-	public function edit()
140
+	public function edit(): void
141 141
 	{
142 142
 		$data = $this->request->getParsedBody();
143 143
 		if (array_key_exists('hummingbird_id', $data))

Loading…
Cancel
Save