-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2530 from acterglobal/ben-selective-calendar-sync
Selective calendar sync
- Loading branch information
Showing
28 changed files
with
977 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- You can now deselect calendar sync of specific spaces in their settings to exclude them from showing in your device calendar (on supported devices) |
23 changes: 23 additions & 0 deletions
23
app/lib/features/calendar_sync/actions/set_room_sync_preference.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:acter/features/room/providers/user_settings_provider.dart'; | ||
import 'package:flutter_easyloading/flutter_easyloading.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
import 'package:logging/logging.dart'; | ||
|
||
final _log = Logger('a3::space::actions::activate'); | ||
|
||
Future<bool> setRoomSyncPreference( | ||
WidgetRef ref, | ||
L10n lang, | ||
String roomId, | ||
bool newValue, | ||
) async { | ||
try { | ||
final settings = await ref.read(roomUserSettingsProvider(roomId).future); | ||
return await settings.setIncludeCalSync(newValue); | ||
} catch (e, s) { | ||
_log.severe('Setting room calendar settings failed', e, s); | ||
EasyLoading.showError(lang.error(e)); | ||
return false; | ||
} | ||
} |
20 changes: 18 additions & 2 deletions
20
app/lib/features/calendar_sync/providers/events_to_sync_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/lib/features/room/providers/notifiers/user_settings_notifier.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:acter/common/providers/room_providers.dart'; | ||
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart' | ||
show UserRoomSettings; | ||
import 'package:riverpod/riverpod.dart'; | ||
|
||
class AsyncUserRoomSettingsNotifier | ||
extends AutoDisposeFamilyAsyncNotifier<UserRoomSettings, String> { | ||
late Stream<bool> _listener; | ||
|
||
Future<void> reload(String roomId) async { | ||
state = AsyncData(await fetch(roomId)); | ||
} | ||
|
||
Future<UserRoomSettings> fetch(String roomId) async { | ||
final room = await ref.watch(maybeRoomProvider(roomId).future); | ||
if (room == null) { | ||
throw RoomNotFound(); | ||
} | ||
return await room.userSettings(); | ||
} | ||
|
||
@override | ||
Future<UserRoomSettings> build(String arg) async { | ||
final settings = await fetch(arg); | ||
_listener = settings.subscribeStream(); // keep it resident in memory | ||
_listener.forEach((e) async { | ||
reload(arg); | ||
}); | ||
return settings; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'package:acter/features/room/providers/notifiers/user_settings_notifier.dart'; | ||
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
final roomUserSettingsProvider = AsyncNotifierProvider.autoDispose | ||
.family<AsyncUserRoomSettingsNotifier, UserRoomSettings, String>( | ||
() => AsyncUserRoomSettingsNotifier(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.