toggleLike method

Future<void> toggleLike(
  1. int postId
)

Implementation

Future<void> toggleLike(int postId) async {
  final token = await CommunityStorage.getAuthToken();
  if (token == null) {
    Get.snackbar('Error', CommunityMessages.loginRequiredLike);
    return;
  }

  try {
    requireSmartLinksNativeBridge();
    final result = await SmartLinksNativeApi.togglePostLike(
      postId: postId,
      authToken: token,
    );
    if (result != null) {
      _applyPostLikeUpdate(postId);
    }
  } catch (e) {
    Get.snackbar('Error', CommunityMessages.likeFailed);
  }
}