-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Will be used to facilitate backup-restore functionality Issue: #41
- Loading branch information
1 parent
525ace4
commit 08ab6d8
Showing
3 changed files
with
16 additions
and
10 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
22 changes: 12 additions & 10 deletions
22
lib/data/repository/favorite_post/entity/favorite_post.dart
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 |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import 'package:boorusphere/data/repository/booru/entity/post.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:hive/hive.dart'; | ||
|
||
part 'favorite_post.freezed.dart'; | ||
part 'favorite_post.g.dart'; | ||
|
||
@HiveType(typeId: 5, adapterName: 'FavoritePostAdapter') | ||
class FavoritePost { | ||
const FavoritePost({ | ||
this.post = Post.empty, | ||
this.timestamp = 0, | ||
}); | ||
@freezed | ||
class FavoritePost with _$FavoritePost { | ||
@HiveType(typeId: 5, adapterName: 'FavoritePostAdapter') | ||
const factory FavoritePost({ | ||
@HiveField(0, defaultValue: Post.empty) @Default(Post.empty) Post post, | ||
@HiveField(1, defaultValue: 0) @Default(0) int timestamp, | ||
}) = _FavoritePost; | ||
const FavoritePost._(); | ||
|
||
@HiveField(0, defaultValue: Post.empty) | ||
final Post post; | ||
@HiveField(1, defaultValue: 0) | ||
final int timestamp; | ||
factory FavoritePost.fromJson(Map<String, dynamic> json) => | ||
_$FavoritePostFromJson(json); | ||
|
||
String get key => '${post.id}@${post.serverId}'; | ||
} |
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