mirror of
https://gitlab.com/mysocialportal/relatica
synced 2024-10-18 12:23:31 +00:00
Perform capabilities check on liking/unliking
This commit is contained in:
parent
dfb3474bd3
commit
a6815ca72b
2 changed files with 25 additions and 3 deletions
|
@ -161,12 +161,15 @@ class _InteractionsBarControlState extends State<InteractionsBarControl> {
|
|||
}
|
||||
|
||||
Widget buildLikeButton() {
|
||||
final canReact = widget.entry.getCanReact();
|
||||
final tooltip =
|
||||
canReact.canDo ? 'Press to toggle like/unlike' : canReact.reason;
|
||||
return buildButton(
|
||||
isFavorited ? Icons.thumb_up : Icons.thumb_up_outlined,
|
||||
likes,
|
||||
true,
|
||||
'Press to toggle like/unlike',
|
||||
() async => await toggleFavorited(),
|
||||
tooltip,
|
||||
canReact.canDo ? () async => await toggleFavorited() : null,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,31 @@ extension InteractionAvailabilityExtension on TimelineEntry {
|
|||
);
|
||||
}
|
||||
|
||||
return InteractionCapabilityResult(
|
||||
return const InteractionCapabilityResult(
|
||||
canDo: true,
|
||||
reason: "Can comment on item",
|
||||
);
|
||||
}
|
||||
|
||||
InteractionCapabilityResult getCanReact() {
|
||||
final settingsService = getIt<SettingsService>();
|
||||
final nc = settingsService.networkCapabilities
|
||||
.getCapabilities(networkInfo.network);
|
||||
|
||||
if (!nc.react) {
|
||||
return InteractionCapabilityResult(
|
||||
canDo: false,
|
||||
reason:
|
||||
"User disabled reacting on ${networkInfo.network.labelName} items. Go into settings to change.",
|
||||
);
|
||||
}
|
||||
|
||||
return const InteractionCapabilityResult(
|
||||
canDo: true,
|
||||
reason: "Can react on item",
|
||||
);
|
||||
}
|
||||
|
||||
InteractionCapabilityResult getIsReshareable(bool isMine) {
|
||||
if (isMine) {
|
||||
return const InteractionCapabilityResult(
|
||||
|
|
Loading…
Reference in a new issue