Skip to content

Commit

Permalink
use new field to sort last read mangas
Browse files Browse the repository at this point in the history
  • Loading branch information
akabhirav committed Feb 21, 2023
1 parent 73defc3 commit 99b4d5e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ class CategoryMangaListWithQueryAndFilter
return (m1.inLibraryAt ?? 0).compareTo(m2.inLibraryAt ?? 0) *
sortDirToggle;
case MangaSort.lastRead:
return (m1.lastChapterRead?.lastReadAt ?? 0)
.compareTo(m2.lastChapterRead?.lastReadAt ?? 0) *
sortDirToggle *
-1;
return (m2.lastReadAt ?? 0).compareTo(m1.lastReadAt ?? 0) *
sortDirToggle;
default:
return 0;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/src/features/manga_book/domain/manga/manga_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Manga with _$Manga {
String? description,
int? downloadCount,
int? chapterCount,
int? lastReadAt,
Chapter? lastChapterRead,
bool? freshData,
List<String>? genre,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mixin _$Manga {
String? get description => throw _privateConstructorUsedError;
int? get downloadCount => throw _privateConstructorUsedError;
int? get chapterCount => throw _privateConstructorUsedError;
int? get lastReadAt => throw _privateConstructorUsedError;
Chapter? get lastChapterRead => throw _privateConstructorUsedError;
bool? get freshData => throw _privateConstructorUsedError;
List<String>? get genre => throw _privateConstructorUsedError;
Expand Down Expand Up @@ -61,6 +62,7 @@ abstract class $MangaCopyWith<$Res> {
String? description,
int? downloadCount,
int? chapterCount,
int? lastReadAt,
Chapter? lastChapterRead,
bool? freshData,
List<String>? genre,
Expand Down Expand Up @@ -104,6 +106,7 @@ class _$MangaCopyWithImpl<$Res, $Val extends Manga>
Object? description = freezed,
Object? downloadCount = freezed,
Object? chapterCount = freezed,
Object? lastReadAt = freezed,
Object? lastChapterRead = freezed,
Object? freshData = freezed,
Object? genre = freezed,
Expand Down Expand Up @@ -144,6 +147,10 @@ class _$MangaCopyWithImpl<$Res, $Val extends Manga>
? _value.chapterCount
: chapterCount // ignore: cast_nullable_to_non_nullable
as int?,
lastReadAt: freezed == lastReadAt
? _value.lastReadAt
: lastReadAt // ignore: cast_nullable_to_non_nullable
as int?,
lastChapterRead: freezed == lastChapterRead
? _value.lastChapterRead
: lastChapterRead // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -268,6 +275,7 @@ abstract class _$$_MangaCopyWith<$Res> implements $MangaCopyWith<$Res> {
String? description,
int? downloadCount,
int? chapterCount,
int? lastReadAt,
Chapter? lastChapterRead,
bool? freshData,
List<String>? genre,
Expand Down Expand Up @@ -310,6 +318,7 @@ class __$$_MangaCopyWithImpl<$Res> extends _$MangaCopyWithImpl<$Res, _$_Manga>
Object? description = freezed,
Object? downloadCount = freezed,
Object? chapterCount = freezed,
Object? lastReadAt = freezed,
Object? lastChapterRead = freezed,
Object? freshData = freezed,
Object? genre = freezed,
Expand Down Expand Up @@ -350,6 +359,10 @@ class __$$_MangaCopyWithImpl<$Res> extends _$MangaCopyWithImpl<$Res, _$_Manga>
? _value.chapterCount
: chapterCount // ignore: cast_nullable_to_non_nullable
as int?,
lastReadAt: freezed == lastReadAt
? _value.lastReadAt
: lastReadAt // ignore: cast_nullable_to_non_nullable
as int?,
lastChapterRead: freezed == lastChapterRead
? _value.lastChapterRead
: lastChapterRead // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -435,6 +448,7 @@ class _$_Manga implements _Manga {
this.description,
this.downloadCount,
this.chapterCount,
this.lastReadAt,
this.lastChapterRead,
this.freshData,
final List<String>? genre,
Expand Down Expand Up @@ -470,6 +484,8 @@ class _$_Manga implements _Manga {
@override
final int? chapterCount;
@override
final int? lastReadAt;
@override
final Chapter? lastChapterRead;
@override
final bool? freshData;
Expand Down Expand Up @@ -517,7 +533,7 @@ class _$_Manga implements _Manga {

@override
String toString() {
return 'Manga(artist: $artist, author: $author, description: $description, downloadCount: $downloadCount, chapterCount: $chapterCount, lastChapterRead: $lastChapterRead, freshData: $freshData, genre: $genre, inLibrary: $inLibrary, id: $id, inLibraryAt: $inLibraryAt, initialized: $initialized, realUrl: $realUrl, source: $source, sourceId: $sourceId, status: $status, thumbnailUrl: $thumbnailUrl, title: $title, unreadCount: $unreadCount, lastFetchedAt: $lastFetchedAt, chaptersLastFetchedAt: $chaptersLastFetchedAt, url: $url, meta: $meta)';
return 'Manga(artist: $artist, author: $author, description: $description, downloadCount: $downloadCount, chapterCount: $chapterCount, lastReadAt: $lastReadAt, lastChapterRead: $lastChapterRead, freshData: $freshData, genre: $genre, inLibrary: $inLibrary, id: $id, inLibraryAt: $inLibraryAt, initialized: $initialized, realUrl: $realUrl, source: $source, sourceId: $sourceId, status: $status, thumbnailUrl: $thumbnailUrl, title: $title, unreadCount: $unreadCount, lastFetchedAt: $lastFetchedAt, chaptersLastFetchedAt: $chaptersLastFetchedAt, url: $url, meta: $meta)';
}

@override
Expand All @@ -533,6 +549,8 @@ class _$_Manga implements _Manga {
other.downloadCount == downloadCount) &&
(identical(other.chapterCount, chapterCount) ||
other.chapterCount == chapterCount) &&
(identical(other.lastReadAt, lastReadAt) ||
other.lastReadAt == lastReadAt) &&
(identical(other.lastChapterRead, lastChapterRead) ||
other.lastChapterRead == lastChapterRead) &&
(identical(other.freshData, freshData) ||
Expand Down Expand Up @@ -572,6 +590,7 @@ class _$_Manga implements _Manga {
description,
downloadCount,
chapterCount,
lastReadAt,
lastChapterRead,
freshData,
const DeepCollectionEquality().hash(_genre),
Expand Down Expand Up @@ -613,6 +632,7 @@ abstract class _Manga implements Manga {
final String? description,
final int? downloadCount,
final int? chapterCount,
final int? lastReadAt,
final Chapter? lastChapterRead,
final bool? freshData,
final List<String>? genre,
Expand Down Expand Up @@ -646,6 +666,8 @@ abstract class _Manga implements Manga {
@override
int? get chapterCount;
@override
int? get lastReadAt;
@override
Chapter? get lastChapterRead;
@override
bool? get freshData;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/features/manga_book/domain/manga/manga_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 99b4d5e

Please sign in to comment.