Enhanced material design 3 implementation
This commit is contained in:
@@ -26,9 +26,11 @@ final showPastSchedulesProvider = StateProvider<bool>((ref) => false);
|
||||
|
||||
final dutySchedulesProvider = StreamProvider<List<DutySchedule>>((ref) {
|
||||
final client = ref.watch(supabaseClientProvider);
|
||||
final profileAsync = ref.watch(currentProfileProvider);
|
||||
final profile = profileAsync.valueOrNull;
|
||||
if (profile == null) {
|
||||
// Only recreate stream when user id changes (not on other profile edits).
|
||||
final profileId = ref.watch(
|
||||
currentProfileProvider.select((p) => p.valueOrNull?.id),
|
||||
);
|
||||
if (profileId == null) {
|
||||
return Stream.value(const <DutySchedule>[]);
|
||||
}
|
||||
|
||||
@@ -95,16 +97,21 @@ final dutySchedulesForUserProvider =
|
||||
|
||||
final swapRequestsProvider = StreamProvider<List<SwapRequest>>((ref) {
|
||||
final client = ref.watch(supabaseClientProvider);
|
||||
final profileAsync = ref.watch(currentProfileProvider);
|
||||
final profile = profileAsync.valueOrNull;
|
||||
if (profile == null) {
|
||||
// Only recreate stream when user id or role changes.
|
||||
final profileId = ref.watch(
|
||||
currentProfileProvider.select((p) => p.valueOrNull?.id),
|
||||
);
|
||||
final profileRole = ref.watch(
|
||||
currentProfileProvider.select((p) => p.valueOrNull?.role),
|
||||
);
|
||||
if (profileId == null) {
|
||||
return Stream.value(const <SwapRequest>[]);
|
||||
}
|
||||
|
||||
final isAdmin =
|
||||
profile.role == 'admin' ||
|
||||
profile.role == 'programmer' ||
|
||||
profile.role == 'dispatcher';
|
||||
profileRole == 'admin' ||
|
||||
profileRole == 'programmer' ||
|
||||
profileRole == 'dispatcher';
|
||||
|
||||
final wrapper = StreamRecoveryWrapper<SwapRequest>(
|
||||
stream: isAdmin
|
||||
@@ -135,7 +142,7 @@ final swapRequestsProvider = StreamProvider<List<SwapRequest>>((ref) {
|
||||
// either party. admins still see "admin_review" rows so they can act on
|
||||
// escalated cases.
|
||||
return result.data.where((row) {
|
||||
if (!(row.requesterId == profile.id || row.recipientId == profile.id)) {
|
||||
if (!(row.requesterId == profileId || row.recipientId == profileId)) {
|
||||
return false;
|
||||
}
|
||||
// only keep pending and admin_review statuses
|
||||
|
||||
Reference in New Issue
Block a user