Skip to content

Commit f9f6aa5

Browse files
committed
feat(app_configuration): disable role selection for link_account decorator
- Disable checkbox for standard and premium users when selecting roles for link_account decorator - Keep the functionality intact for other decorator types and user roles
1 parent e419a32 commit f9f6aa5

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

lib/app_configuration/view/app_configuration_page.dart

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,31 +1132,35 @@ class _FeedDecoratorFormState extends State<_FeedDecoratorForm> {
11321132
CheckboxListTile(
11331133
title: Text(role.l10n(context)),
11341134
value: roleConfig != null,
1135-
onChanged: (value) {
1136-
final newVisibleTo =
1137-
Map<AppUserRole, FeedDecoratorRoleConfig>.from(
1138-
decoratorConfig.visibleTo,
1139-
);
1140-
if (value == true) {
1141-
newVisibleTo[role] = const FeedDecoratorRoleConfig(
1142-
daysBetweenViews: 7,
1143-
);
1144-
} else {
1145-
newVisibleTo.remove(role);
1146-
}
1147-
final newDecoratorConfig = decoratorConfig.copyWith(
1148-
visibleTo: newVisibleTo,
1149-
);
1150-
final newFeedDecoratorConfig =
1151-
Map<FeedDecoratorType, FeedDecoratorConfig>.from(
1152-
widget.remoteConfig.feedDecoratorConfig,
1153-
)..[widget.decoratorType] = newDecoratorConfig;
1154-
widget.onConfigChanged(
1155-
widget.remoteConfig.copyWith(
1156-
feedDecoratorConfig: newFeedDecoratorConfig,
1157-
),
1158-
);
1159-
},
1135+
onChanged: widget.decoratorType == FeedDecoratorType.linkAccount &&
1136+
(role == AppUserRole.standardUser ||
1137+
role == AppUserRole.premiumUser)
1138+
? null // Disable for standard and premium users for linkAccount
1139+
: (value) {
1140+
final newVisibleTo =
1141+
Map<AppUserRole, FeedDecoratorRoleConfig>.from(
1142+
decoratorConfig.visibleTo,
1143+
);
1144+
if (value == true) {
1145+
newVisibleTo[role] = const FeedDecoratorRoleConfig(
1146+
daysBetweenViews: 7,
1147+
);
1148+
} else {
1149+
newVisibleTo.remove(role);
1150+
}
1151+
final newDecoratorConfig = decoratorConfig.copyWith(
1152+
visibleTo: newVisibleTo,
1153+
);
1154+
final newFeedDecoratorConfig =
1155+
Map<FeedDecoratorType, FeedDecoratorConfig>.from(
1156+
widget.remoteConfig.feedDecoratorConfig,
1157+
)..[widget.decoratorType] = newDecoratorConfig;
1158+
widget.onConfigChanged(
1159+
widget.remoteConfig.copyWith(
1160+
feedDecoratorConfig: newFeedDecoratorConfig,
1161+
),
1162+
);
1163+
},
11601164
),
11611165
if (roleConfig != null)
11621166
Padding(

0 commit comments

Comments
 (0)