diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 383d242..db406d0 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -47,5 +47,10 @@
UIApplicationSupportsIndirectInputEvents
+ NSAppTransportSecurity
+
+ NSAllowsArbitraryLoads
+
+
diff --git a/lib/api/cache.dart b/lib/api/cache.dart
index 76139ce..6ae5e8d 100644
--- a/lib/api/cache.dart
+++ b/lib/api/cache.dart
@@ -1,6 +1,6 @@
import 'package:freezer/api/definitions.dart';
+import 'package:freezer/api/paths.dart';
import 'package:hive_flutter/hive_flutter.dart';
-import 'package:json_annotation/json_annotation.dart';
import 'dart:async';
@@ -8,46 +8,82 @@ part 'cache.g.dart';
late Cache cache;
+class CacheEntryAdapter extends TypeAdapter {
+ @override
+ final int typeId = 20;
+
+ @override
+ CacheEntry read(BinaryReader reader) {
+ final numOfFields = reader.readByte();
+ final fields = {
+ for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
+ };
+ return CacheEntry(
+ fields[0],
+ updatedAt: fields[1] as DateTime?,
+ );
+ }
+
+ @override
+ void write(BinaryWriter writer, CacheEntry obj) {
+ writer
+ ..writeByte(2)
+ ..writeByte(0)
+ ..write(obj.value)
+ ..writeByte(1)
+ ..write(obj.updatedAt);
+ }
+
+ @override
+ int get hashCode => typeId.hashCode;
+
+ @override
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is CacheEntryAdapter &&
+ runtimeType == other.runtimeType &&
+ typeId == other.typeId;
+}
+
+class CacheEntry {
+ final T value;
+ final DateTime updatedAt;
+
+ CacheEntry(this.value, {DateTime? updatedAt})
+ : updatedAt = updatedAt ?? DateTime.now();
+}
+
//Cache for miscellaneous things
@HiveType(typeId: 22)
-@JsonSerializable()
class Cache {
- static Future> get _box =>
- Hive.openLazyBox('metacache');
+ static Future> get _box async =>
+ Hive.openLazyBox('metacache', path: await Paths.cacheDir());
//ID's of tracks that are in library
@HiveField(0, defaultValue: [])
- @JsonKey(defaultValue: [])
List libraryTracks = [];
//Track ID of logged track, to prevent duplicates
@HiveField(1)
- @JsonKey(includeToJson: false, includeFromJson: false)
String? loggedTrackId;
@HiveField(2)
- @JsonKey(defaultValue: [])
List