Skip to content

Commit 15709a2

Browse files
committed
Fix ical importer doesn't import calendar items, closes #89
1 parent fe81222 commit 15709a2

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

app/lib/l10n/app_en.arb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,5 +309,14 @@
309309
"updateNow": "Update now",
310310
"stable": "Stable",
311311
"nightly": "Nightly",
312-
"updateAvailable": "Update available"
312+
"updateAvailable": "Update available",
313+
"countItems": "{count, plural, =0 {No items} one {1 item} other {{count} items}}",
314+
"@countItems": {
315+
"placeholders": {
316+
"count": {
317+
"type": "int",
318+
"example": "1"
319+
}
320+
}
321+
}
313322
}

app/lib/pages/sources/dialog.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,21 @@ class AddSourceDialog extends StatelessWidget {
121121
final converter = ICalConverter();
122122
converter.read(lines);
123123
final events = converter.data?.events ?? [];
124+
final items = converter.data?.items ?? [];
124125
if (context.mounted) {
125126
final success = await showDialog<bool>(
126127
context: context,
127-
builder: (context) => ImportDialog(events: events),
128+
builder: (context) =>
129+
ImportDialog(events: events, items: items),
128130
);
129131
if (success != true) return;
130132
final service = cubit.getCurrentService().event;
131133
await Future.wait(events
132134
.map((event) async => service?.createEvent(event)));
135+
await Future.wait(items.map((item) async => cubit
136+
.getCurrentService()
137+
.calendarItem
138+
?.createCalendarItem(item)));
133139
}
134140
if (context.mounted) {
135141
Navigator.of(context).pop();

app/lib/pages/sources/import.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import 'package:flow_api/models/event/item/model.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flow/src/generated/i18n/app_localizations.dart';
34
import 'package:flow_api/models/event/model.dart';
45

56
class ImportDialog extends StatelessWidget {
67
final List<Event> events;
8+
final List<CalendarItem> items;
79

8-
const ImportDialog({super.key, required this.events});
10+
const ImportDialog({super.key, required this.events, required this.items});
911

1012
@override
1113
Widget build(BuildContext context) {
@@ -15,6 +17,8 @@ class ImportDialog extends StatelessWidget {
1517
mainAxisSize: MainAxisSize.min,
1618
children: [
1719
Text(AppLocalizations.of(context).countEvents(events.length)),
20+
const SizedBox(height: 8),
21+
Text(AppLocalizations.of(context).countItems(items.length)),
1822
],
1923
),
2024
actions: [

metadata/en-US/changelogs/11.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* Fix safe area of navigation drawer
2+
* Fix ical importer doesn't import calendar items ([#89](https://github.com/LinwoodDev/Flow/issues/89))
23

34
Read more here: https://linwood.dev/flow/0.4.2

0 commit comments

Comments
 (0)