-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(playbutton_card): play and add to queue needs 2 clicks work
feat: add disk caching to liked tracks and categories query
- Loading branch information
Showing
5 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
extension CastDeepMaps on Map { | ||
Map<K2, dynamic> castKeyDeep<K2>() { | ||
return cast<K2, dynamic>().map((key, value) { | ||
if (value is Map) { | ||
return MapEntry(key, value.castKeyDeep<K2>()); | ||
} else if (value is List) { | ||
return MapEntry( | ||
key, | ||
value.map((e) => e is Map ? e.castKeyDeep<K2>() : e).toList(), | ||
); | ||
} | ||
return MapEntry(key, value); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:spotify/spotify.dart'; | ||
|
||
extension CursorPageJson<T> on CursorPage<T> { | ||
static CursorPage<T> fromJson<T>( | ||
Map<String, dynamic> json, | ||
T Function(dynamic json) itemFromJson, | ||
) { | ||
final metadata = Paging.fromJson(json["metadata"]); | ||
final paging = CursorPaging<T>(); | ||
paging.cursors = Cursor.fromJson(json["metadata"])..after = json["after"]; | ||
paging.href = metadata.href; | ||
paging.itemsNative = paging.itemsNative; | ||
paging.limit = metadata.limit; | ||
paging.next = metadata.next; | ||
return CursorPage<T>( | ||
paging, | ||
itemFromJson, | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
"after": after, | ||
"metadata": metadata.toJson(), | ||
}; | ||
} | ||
} | ||
|
||
extension PagingToJson<T> on Paging<T> { | ||
Map<String, dynamic> toJson() { | ||
return { | ||
"items": itemsNative, | ||
"total": total, | ||
"next": next, | ||
"previous": previous, | ||
"limit": limit, | ||
"offset": offset, | ||
"href": href, | ||
}; | ||
} | ||
} | ||
|
||
extension PageJson<T> on Page<T> { | ||
static Page<T> fromJson<T>( | ||
Map<String, dynamic> json, | ||
T Function(dynamic json) itemFromJson, | ||
) { | ||
return Page<T>( | ||
Paging<T>.fromJson( | ||
Map.castFrom<dynamic, dynamic, String, dynamic>(json["metadata"]), | ||
), | ||
itemFromJson, | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
"metadata": metadata.toJson(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters