Skip to content

Commit

Permalink
drop: RepositoryV2
Browse files Browse the repository at this point in the history
wip #377
  • Loading branch information
zin- committed Sep 7, 2024
1 parent d41dc3a commit da45751
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
2 changes: 0 additions & 2 deletions lib/framework/repository/entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// # 語源
//
// 「存在するもの」、「実体」
abstract class EntityV2 {}

abstract class EntityV1 {}

mixin Entity {
Expand Down
12 changes: 0 additions & 12 deletions lib/framework/repository/repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,4 @@ import 'package:mem/framework/repository/entity.dart';
// 抽象的には得ると捉える事もできるだろうが、では`update`(更新する)ことはあるだろうか?
// 更新することはないように感じる
// よって、ここでは`receive`(受け取る)、`replace`(置き換える)などの荷物や事物を扱う際の単語を採用する
abstract class RepositoryV2<E extends EntityV2> {}

mixin Receiver<E extends EntityV2, Result> on RepositoryV2<E> {
Future<Result> receive(E entity);
}

// FIXME 型指定は不要なはずなので、おかしい?(間違っている気がする
// というか、mixinの利用自体がなんか変なので辞めたほうが良いかも
mixin Discarder<E extends EntityV2> on RepositoryV2<E> {
Future<void> discardAll();
}

abstract class Repository<E extends Entity> {}
2 changes: 2 additions & 0 deletions lib/logger/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ class Log with Entity {
return elements.join('\n');
}

// coverage:ignore-start
@override
// TODO: implement copiedWith
Entity copiedWith() => throw UnimplementedError();

@override
// TODO: implement toMap
Map<String, dynamic> get toMap => throw UnimplementedError();
// coverage:ignore-end
}

enum Level {
Expand Down
29 changes: 20 additions & 9 deletions lib/notifications/schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:mem/notifications/notification_client.dart';
import 'package:mem/notifications/mem_notifications.dart';
import 'package:mem/notifications/notification/type.dart';

abstract class Schedule extends EntityV2 {
abstract class Schedule with Entity {
final int id;

Schedule(this.id);
Expand Down Expand Up @@ -34,10 +34,17 @@ abstract class Schedule extends EntityV2 {
},
);

// coverage:ignore-start
@override
String toString() => "${super.toString()}: ${{
"id": id,
}}";
// TODO: implement copiedWith
Entity copiedWith() => throw UnimplementedError();

// coverage:ignore-end

@override
Map<String, dynamic> get toMap => {
'id': id,
};
}

class CancelSchedule extends Schedule {
Expand All @@ -55,10 +62,11 @@ class TimedSchedule extends Schedule {
);

@override
String toString() => "${super.toString()}${{
"startAt": startAt,
"params": params,
}}";
Map<String, dynamic> get toMap => super.toMap
..addAll({
'startAt': startAt,
'params': params,
});
}

class PeriodicSchedule extends TimedSchedule {
Expand All @@ -72,5 +80,8 @@ class PeriodicSchedule extends TimedSchedule {
);

@override
String toString() => "${super.toString()}${{"duration": duration}}";
Map<String, dynamic> get toMap => super.toMap
..addAll({
'duration': duration,
});
}
4 changes: 1 addition & 3 deletions lib/notifications/schedule_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import 'package:mem/notifications/schedule.dart';
import 'package:mem/permissions/permission.dart';
import 'package:mem/permissions/permission_handler_wrapper.dart';

class ScheduleClient extends RepositoryV2<Schedule>
with Receiver<Schedule, void> {
class ScheduleClient extends Repository<Schedule> {
static ScheduleClient? _instance;
final AndroidAlarmManagerWrapper _androidAlarmManagerWrapper;
final Future<void> Function(int id, Map<String, dynamic> params)
Expand Down Expand Up @@ -40,7 +39,6 @@ class ScheduleClient extends RepositoryV2<Schedule>
},
);

@override
Future<void> receive(Schedule entity) => v(
() async {
if (await PermissionHandlerWrapper().grant(Permission.notification)) {
Expand Down

0 comments on commit da45751

Please sign in to comment.