Skip to content

Commit

Permalink
refactor(replies): revert naming of default replies
Browse files Browse the repository at this point in the history
  • Loading branch information
mforesti committed Dec 5, 2024
1 parent 62e7e2b commit c728f4c
Show file tree
Hide file tree
Showing 36 changed files with 526 additions and 566 deletions.
2 changes: 1 addition & 1 deletion lib/actions/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export 'app.dart';
export 'auth.dart';
export 'date.dart';
export 'deeplinks.dart';
export 'default_rules.dart';
export 'default_replies.dart';
export 'groups.dart';
export 'invites.dart';
export 'locale.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:flutter/foundation.dart';

@immutable
class RequestDeleteDefaultRuleAction {
class RequestDeleteDefaultReplyAction {
final int memberId;
final int scheduleId;

const RequestDeleteDefaultRuleAction({
const RequestDeleteDefaultReplyAction({
required this.memberId,
required this.scheduleId,
});
Expand Down
59 changes: 59 additions & 0 deletions lib/epics/default_replies.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:parousia/actions/actions.dart';
import 'package:parousia/models/models.dart';
import 'package:parousia/repositories/repositories.dart';
import 'package:parousia/state/state.dart';
import 'package:redux_entity/redux_entity.dart';
import 'package:redux_epics/redux_epics.dart';
import 'package:rxdart/rxdart.dart';

createDefaultRepliesEpics(DefaultRepliesRepository defaultReplies) =>
combineEpics<AppState>([
_createRetrieveGroupDefaultRepliesEpic(defaultReplies),
_createRequestUpdateOneDefaultReplyEpic(defaultReplies),
_createRequestDeleteDefaultReplyEpic(defaultReplies),
]);

/// Fetch all default replies for a group
Epic<AppState> _createRetrieveGroupDefaultRepliesEpic(
DefaultRepliesRepository defaultReplies) {
return (Stream<dynamic> actions, EpicStore<AppState> store) => actions
.whereType<GroupDetailsOpenAction>()
.asyncMap(
(action) => defaultReplies
.getDefaultReplies(int.parse(action.groupId))
.then<dynamic>((defaultReplies) =>
SuccessRetrieveMany(defaultReplies.toList(growable: false)))
.catchError((error) => FailRetrieveMany<DefaultReply>([], error)),
);
}

/// Create a new default reply
Epic<AppState> _createRequestUpdateOneDefaultReplyEpic(
DefaultRepliesRepository defaultReplies) {
return (Stream<dynamic> actions, EpicStore<AppState> store) =>
actions.whereType<RequestUpdateOne<DefaultReply>>().asyncMap(
(action) => defaultReplies
.createDefaultReply(action.entity)
.then<dynamic>((defaultReply) => SuccessUpdateOne(defaultReply))
.catchError((error) => FailUpdateOne<DefaultReply>(
entity: action.entity, error: error)),
);
}

/// Delete a default reply
Epic<AppState> _createRequestDeleteDefaultReplyEpic(
DefaultRepliesRepository defaultReplies) {
return (Stream<dynamic> actions, EpicStore<AppState> store) =>
actions.whereType<RequestDeleteDefaultReplyAction>().asyncMap(
(action) => defaultReplies
.deleteDefaultReply(
memberId: action.memberId,
scheduleId: action.scheduleId,
)
.then<dynamic>((_) => SuccessDeleteOne<DefaultReply>(
"${action.memberId}-${action.scheduleId}"))
.catchError((error) => FailDeleteOne<DefaultReply>(
id: "${action.memberId}-${action.scheduleId}",
error: error)),
);
}
59 changes: 0 additions & 59 deletions lib/epics/default_rules.dart

This file was deleted.

2 changes: 1 addition & 1 deletion lib/epics/epics.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export 'auth.dart';
export 'default_rules.dart';
export 'default_replies.dart';
export 'groups.dart';
export 'invites.dart';
export 'members.dart';
Expand Down
11 changes: 6 additions & 5 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"createNewEvent": "Neues Event erstellen",
"createNewGroup": "Neue Gruppe erstellen",
"createOrJoinGroup": "Gruppe erstellen oder beitreten",
"defaultRules": "Standardantworten",
"defaultRulesDescription": "Wähle eine Standardantwort für dieses Event",
"defaultRulesDaily": "Täglich",
"defaultRulesWeekdays": "Wochentage",
"defaultRulesWeekends": "Wochenende",
"defaultReplies": "Standardantworten",
"defaultRepliesDescription": "Wähle eine Standardantwort für dieses Event",
"defaultRepliesDaily": "Täglich",
"defaultRepliesExplanation": "Standardantworten ermöglichen es dir, automatische Antworten für wiederkehrende Events festzulegen. Du kannst zwischen täglichen, wochentäglichen oder wochenendlichen Optionen wählen.",
"defaultRepliesWeekdays": "Wochentage",
"defaultRepliesWeekends": "Wochenende",
"delete": "Löschen",
"deleteGroup": "Gruppe löschen",
"deleteGroupConfirmation": "Bist du sicher, dass du diese Gruppe löschen möchtest?",
Expand Down
11 changes: 6 additions & 5 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"createNewEvent": "Create new event",
"createNewGroup": "Create new group",
"createOrJoinGroup": "Create or join group",
"defaultRules": "Default replies",
"defaultRulesDescription": "Choose a default reply to apply to this event",
"defaultRulesDaily": "Daily",
"defaultRulesWeekdays": "Weekdays",
"defaultRulesWeekends": "Weekends",
"defaultReplies": "Default replies",
"defaultRepliesDescription": "Choose a default reply to apply to this event",
"defaultRepliesDaily": "Daily",
"defaultRepliesExplanation": "Default replies allow you to set automatic responses for recurring events. You can choose from daily, weekdays, or weekends options.",
"defaultRepliesWeekdays": "Weekdays",
"defaultRepliesWeekends": "Weekends",
"delete": "Delete",
"deleteGroup": "Delete group",
"deleteGroupConfirmation": "Are you sure you want to delete this group?",
Expand Down
11 changes: 6 additions & 5 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"createNewEvent": "Crea un evento nuevo",
"createNewGroup": "Crea un grupo nuevo",
"createOrJoinGroup": "Crea o únete a un grupo",
"defaultRules": "Respuestas predeterminadas",
"defaultRulesDescription": "Elige una respuesta predeterminada para este evento",
"defaultRulesDaily": "Diario",
"defaultRulesWeekdays": "Días laborables",
"defaultRulesWeekends": "Fines de semana",
"defaultReplies": "Respuestas predeterminadas",
"defaultRepliesDescription": "Elige una respuesta predeterminada para este evento",
"defaultRepliesDaily": "Diario",
"defaultRepliesExplanation": "Las respuestas predeterminadas te permiten establecer respuestas automáticas para eventos recurrentes. Puedes elegir entre opciones diarias, de días laborables o de fines de semana.",
"defaultRepliesWeekdays": "Días laborables",
"defaultRepliesWeekends": "Fines de semana",
"delete": "Eliminar",
"deleteGroup": "Eliminar grupo",
"deleteGroupConfirmation": "¿Estás seguro de que quieres eliminar este grupo?",
Expand Down
11 changes: 6 additions & 5 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"createNewEvent": "Crée un nouvel événement",
"createNewGroup": "Crée un nouveau groupe",
"createOrJoinGroup": "Crée ou rejoins un groupe",
"defaultRules": "Réponses par défaut",
"defaultRulesDescription": "Choisis une réponse par défaut pour cet événement",
"defaultRulesDaily": "Quotidien",
"defaultRulesWeekdays": "Jours de semaine",
"defaultRulesWeekends": "Week-ends",
"defaultReplies": "Réponses par défaut",
"defaultRepliesDescription": "Choisis une réponse par défaut pour cet événement",
"defaultRepliesDaily": "Quotidien",
"defaultRepliesExplanation": "Les réponses par défaut te permettent de définir des réponses automatiques pour les événements récurrents. Tu peux choisir entre des options quotidiennes, en semaine ou le week-end.",
"defaultRepliesWeekdays": "Jours de semaine",
"defaultRepliesWeekends": "Week-ends",
"delete": "Supprime",
"deleteGroup": "Supprime le groupe",
"deleteGroupConfirmation": "Es-tu sûr de vouloir supprimer ce groupe?",
Expand Down
11 changes: 6 additions & 5 deletions lib/l10n/app_it.arb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"createNewEvent": "Crea un nuovo evento",
"createNewGroup": "Crea un nuovo gruppo",
"createOrJoinGroup": "Crea o unisciti a un gruppo",
"defaultRules": "Risposte predefinite",
"defaultRulesDescription": "Scegli una risposta predefinita per questo evento",
"defaultRulesDaily": "Giornaliero",
"defaultRulesWeekdays": "Giorni feriali",
"defaultRulesWeekends": "Fine settimana",
"defaultReplies": "Risposte predefinite",
"defaultRepliesDescription": "Scegli una risposta predefinita per questo evento",
"defaultRepliesExplanation": "Le risposte predefinite ti permettono di impostare risposte automatiche per eventi ricorrenti. Puoi scegliere tra opzioni giornaliere, nei giorni feriali o nei fine settimana.",
"defaultRepliesDaily": "Giornaliero",
"defaultRepliesWeekdays": "Giorni feriali",
"defaultRepliesWeekends": "Fine settimana",
"delete": "Elimina",
"deleteGroup": "Elimina gruppo",
"deleteGroupConfirmation": "Sei sicuro di voler eliminare questo gruppo?",
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Future<void> main() async {
}

Future<Store<AppState>> _initStore(SupabaseClient supabase) async {
final defaultRulesRepository = DefaultRulesRepository(supabase: supabase);
final defaultRepliesRepository = DefaultRepliesRepository(supabase: supabase);
final groupsRepository = GroupsRepository(supabase: supabase);
final membersRepository = MembersRepository(supabase: supabase);
final invitesRepository = InvitesRepository(supabase: supabase);
Expand All @@ -66,7 +66,7 @@ Future<Store<AppState>> _initStore(SupabaseClient supabase) async {
final epics = combineEpics<AppState>([
createRouterEpics(router),
createAuthEpics(),
createDefaultRulesEpics(defaultRulesRepository),
createDefaultRepliesEpics(defaultRepliesRepository),
createGroupsEpics(groupsRepository),
createMembersEpic(membersRepository),
createInvitesEpics(invitesRepository),
Expand Down
14 changes: 7 additions & 7 deletions lib/models/default_rule.dart → lib/models/default_reply.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import 'package:rrule/rrule.dart';

import 'enum.dart';

part 'default_rule.freezed.dart';
part 'default_reply.freezed.dart';

part 'default_rule.g.dart';
part 'default_reply.g.dart';

@freezed
sealed class DefaultRule with _$DefaultRule {
sealed class DefaultReply with _$DefaultReply {
@JsonSerializable(fieldRename: FieldRename.snake)
const factory DefaultRule({
const factory DefaultReply({
required int memberId,
required int scheduleId,
required ReplyOptions selectedOption,
required RecurrenceRule recurrenceRule,
DateTime? createdAt,
DateTime? updatedAt,
}) = _DefaultRule;
}) = _DefaultReply;

factory DefaultRule.fromJson(Map<String, dynamic> json) =>
_$DefaultRuleFromJson(json);
factory DefaultReply.fromJson(Map<String, dynamic> json) =>
_$DefaultReplyFromJson(json);
}
Loading

0 comments on commit c728f4c

Please sign in to comment.