kopia lustrzana https://gitlab.com/mysocialportal/relatica
Perform capabilities check on liking/unliking
Finishes implementation of Issue #93merge-requests/67/merge
rodzic
dfb3474bd3
commit
c7df3ff1ba
|
@ -161,12 +161,15 @@ class _InteractionsBarControlState extends State<InteractionsBarControl> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildLikeButton() {
|
Widget buildLikeButton() {
|
||||||
|
final canReact = widget.entry.getCanReact();
|
||||||
|
final tooltip =
|
||||||
|
canReact.canDo ? 'Press to toggle like/unlike' : canReact.reason;
|
||||||
return buildButton(
|
return buildButton(
|
||||||
isFavorited ? Icons.thumb_up : Icons.thumb_up_outlined,
|
isFavorited ? Icons.thumb_up : Icons.thumb_up_outlined,
|
||||||
likes,
|
likes,
|
||||||
true,
|
true,
|
||||||
'Press to toggle like/unlike',
|
tooltip,
|
||||||
() async => await toggleFavorited(),
|
canReact.canDo ? () async => await toggleFavorited() : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,31 @@ extension InteractionAvailabilityExtension on TimelineEntry {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return InteractionCapabilityResult(
|
return const InteractionCapabilityResult(
|
||||||
canDo: true,
|
canDo: true,
|
||||||
reason: "Can comment on item",
|
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) {
|
InteractionCapabilityResult getIsReshareable(bool isMine) {
|
||||||
if (isMine) {
|
if (isMine) {
|
||||||
return const InteractionCapabilityResult(
|
return const InteractionCapabilityResult(
|
||||||
|
|
Ładowanie…
Reference in New Issue