Improve web calendar layout and shared sync state
This commit is contained in:
+47
-4
@@ -520,6 +520,8 @@ class _HomeShellState extends State<HomeShell> {
|
||||
languageCode: widget.languageCode,
|
||||
onChanged: widget.onGoogleConnectionsChanged,
|
||||
onSyncedEventsChanged: widget.onSyncedEventsChanged,
|
||||
onWorkspaceStateShouldUpload: () =>
|
||||
_uploadWorkspaceState(silent: true),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -969,6 +971,27 @@ class _HomeShellState extends State<HomeShell> {
|
||||
.map(Person.fromJson)
|
||||
.toList()
|
||||
: widget.people;
|
||||
final nextAppCalendars = state['appCalendars'] is List
|
||||
? (state['appCalendars'] as List)
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(AppCalendar.fromJson)
|
||||
.toList()
|
||||
: widget.appCalendars;
|
||||
final nextGoogleConnections = state['googleConnections'] is List
|
||||
? (state['googleConnections'] as List)
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(GoogleCalendarConnection.fromJson)
|
||||
.toList()
|
||||
: widget.googleConnections;
|
||||
final nextSyncedEvents = state['syncedEvents'] is List
|
||||
? (state['syncedEvents'] as List)
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(CalendarEvent.fromJson)
|
||||
.toList()
|
||||
: widget.syncedEvents;
|
||||
final nextTodoSuggestions = state['todoSuggestions'] is List
|
||||
? (state['todoSuggestions'] as List).whereType<String>().toList()
|
||||
: widget.todoSuggestions;
|
||||
final nextShopping = state['shopping'] is List
|
||||
? (state['shopping'] as List)
|
||||
.whereType<Map<String, dynamic>>()
|
||||
@@ -991,6 +1014,10 @@ class _HomeShellState extends State<HomeShell> {
|
||||
..addAll(nextStock);
|
||||
});
|
||||
widget.onPeopleChanged(nextPeople);
|
||||
widget.onAppCalendarsChanged(nextAppCalendars);
|
||||
widget.onGoogleConnectionsChanged(nextGoogleConnections);
|
||||
widget.onSyncedEventsChanged(nextSyncedEvents);
|
||||
widget.onTodoSuggestionsChanged(nextTodoSuggestions);
|
||||
if (!silent) {
|
||||
_showWorkspaceMessage('K\u00f6z\u00f6s munkat\u00e9r let\u00f6ltve.');
|
||||
}
|
||||
@@ -1003,10 +1030,12 @@ class _HomeShellState extends State<HomeShell> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _uploadWorkspaceState() async {
|
||||
Future<void> _uploadWorkspaceState({bool silent = false}) async {
|
||||
final workspaceToken = widget.jarvisSettings.workspaceToken?.trim();
|
||||
if (workspaceToken == null || workspaceToken.isEmpty) {
|
||||
_showWorkspaceMessage('Adj meg k\u00f6z\u00f6s munkat\u00e9r tokent.');
|
||||
if (!silent) {
|
||||
_showWorkspaceMessage('Adj meg k\u00f6z\u00f6s munkat\u00e9r tokent.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1019,6 +1048,16 @@ class _HomeShellState extends State<HomeShell> {
|
||||
'version': 1,
|
||||
'updatedAt': DateTime.now().toIso8601String(),
|
||||
'people': widget.people.map((person) => person.toJson()).toList(),
|
||||
'appCalendars': widget.appCalendars
|
||||
.map((calendar) => calendar.toJson())
|
||||
.toList(),
|
||||
'googleConnections': widget.googleConnections
|
||||
.map((connection) => connection.toJson())
|
||||
.toList(),
|
||||
'syncedEvents': widget.syncedEvents
|
||||
.map((event) => event.toJson())
|
||||
.toList(),
|
||||
'todoSuggestions': widget.todoSuggestions,
|
||||
'shopping': shopping.map((item) => item.toJson()).toList(),
|
||||
'stock': stock.map((item) => item.toJson()).toList(),
|
||||
});
|
||||
@@ -1036,9 +1075,13 @@ class _HomeShellState extends State<HomeShell> {
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('workspace PUT ${response.statusCode}');
|
||||
}
|
||||
_showWorkspaceMessage('K\u00f6z\u00f6s munkat\u00e9r felt\u00f6ltve.');
|
||||
if (!silent) {
|
||||
_showWorkspaceMessage('K\u00f6z\u00f6s munkat\u00e9r felt\u00f6ltve.');
|
||||
}
|
||||
} catch (error) {
|
||||
_showWorkspaceMessage('Workspace hiba: $error');
|
||||
if (!silent) {
|
||||
_showWorkspaceMessage('Workspace hiba: $error');
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => workspaceSyncing = false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user