mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-01-11 22:40:36 +00:00
Merge pull request #564 from Schnitzel5/enhance/calendar
enhanced calendar
This commit is contained in:
commit
4770e96fdf
4 changed files with 24 additions and 14 deletions
|
|
@ -203,9 +203,9 @@ class MihonExtensionService implements ExtensionService {
|
|||
(e) => MChapter(
|
||||
name: e['name'],
|
||||
url: e['url'],
|
||||
dateUpload: e['date_upload'] is int
|
||||
? (e['date_upload'] as int).toString()
|
||||
: e['date_upload'],
|
||||
dateUpload:
|
||||
(e['date_upload'] as int?)?.toString() ??
|
||||
DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
scanlator: e['scanlator'],
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import 'dart:typed_data';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/modules/calendar/providers/calendar_provider.dart';
|
||||
import 'package:mangayomi/modules/widgets/custom_extended_image_provider.dart';
|
||||
|
|
@ -241,7 +243,15 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
|||
|
||||
List<Manga> _getEntriesForDay(DateTime day, List<Manga> data) {
|
||||
return data.where((e) {
|
||||
final temp = DateTime.now().add(Duration(days: e.smartUpdateDays!));
|
||||
final lastChapter = e.chapters
|
||||
.filter()
|
||||
.sortByDateUploadDesc()
|
||||
.findFirstSync();
|
||||
final lastDate = int.tryParse(lastChapter?.dateUpload ?? "");
|
||||
final start = lastDate != null
|
||||
? DateTime.fromMillisecondsSinceEpoch(lastDate)
|
||||
: DateTime.now();
|
||||
final temp = start.add(Duration(days: e.smartUpdateDays!));
|
||||
final predictedDay = "${temp.year}-${temp.month}-${temp.day}";
|
||||
final selectedDay = "${day.year}-${day.month}-${day.day}";
|
||||
return predictedDay == selectedDay;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,11 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
part 'calendar_provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
Stream<List<Manga>> getCalendarStream(
|
||||
Ref ref, {
|
||||
ItemType? itemType,
|
||||
}) async* {
|
||||
Stream<List<Manga>> getCalendarStream(Ref ref, {ItemType? itemType}) async* {
|
||||
yield* isar.mangas
|
||||
.filter()
|
||||
.idIsNotNull()
|
||||
.favoriteEqualTo(true)
|
||||
.itemTypeEqualTo(itemType ?? ItemType.manga)
|
||||
.anyOf([
|
||||
Status.ongoing,
|
||||
|
|
|
|||
|
|
@ -293,12 +293,14 @@ class _UpdatesScreenState extends ConsumerState<UpdatesScreen>
|
|||
)
|
||||
.findAll();
|
||||
final idsToDelete = <Id>[];
|
||||
for (var update in updates) {
|
||||
idsToDelete.add(update.id!);
|
||||
ref
|
||||
.read(synchingProvider(syncId: 1).notifier)
|
||||
.addChangedPart(ActionType.removeUpdate, update.id, "{}", false);
|
||||
}
|
||||
isar.writeTxnSync(() {
|
||||
for (var update in updates) {
|
||||
idsToDelete.add(update.id!);
|
||||
ref
|
||||
.read(synchingProvider(syncId: 1).notifier)
|
||||
.addChangedPart(ActionType.removeUpdate, update.id, "{}", false);
|
||||
}
|
||||
});
|
||||
await isar.writeTxn(() => isar.updates.deleteAll(idsToDelete));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue