Skip to content

Commit

Permalink
Built Support for Offline User Actions (#2529)
Browse files Browse the repository at this point in the history
* built_offline_user_actons_support

* fixed failing tests

* upgraded sdk version

* upgraded dart sdk to 3.4.4

* downgraded build_runner to previous version

* upgraded intl

* resolved versions and upgraded sdk to 3.4.4

* updated workflows

* refactored the no of lines in databasemutationfunctions

* fixed dart format

* fixed run check ignore

* fixed dart format

* covered some uncovered lines

* fixed anlyze bug

* minor commit

* covered some uncovered lines

* raised code coverage

* covered most of the lines

* code coverage raised

* code coverage fixed for all files

* fixed code coverage

* fixed code coverage

* built mocks

* some minor changes
  • Loading branch information
Azad99-9 authored Aug 21, 2024
1 parent d5cf01b commit dc25164
Show file tree
Hide file tree
Showing 116 changed files with 4,488 additions and 1,992 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
- name: Set default branch.
run: git remote set-head origin --auto
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
- name: Running pub get to fetch dependencies
run: flutter pub get
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
- name: Running pub get to fetch dependencies
run: flutter pub get
Expand All @@ -166,7 +166,7 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
architecture: x64
- name: Building for ios
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
- name: Running pub get in talawa_lint
run: cd talawa_lint && flutter pub get && cd ..
Expand Down Expand Up @@ -84,11 +84,11 @@ jobs:
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
flutter-version: '3.22.3'
channel: 'stable'
- uses: dart-lang/setup-dart@v1
with:
sdk: '3.3.0'
sdk: '3.4.4'
- run: |
cd talawa_lint && flutter pub get && cd ..
flutter pub get
Expand Down Expand Up @@ -168,7 +168,7 @@ jobs:
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
- name: Running pub get in talawa_lint
run: cd talawa_lint && flutter pub get && cd ..
Expand Down Expand Up @@ -199,7 +199,7 @@ jobs:
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
- name: Running pub get in talawa_lint
run: cd talawa_lint && flutter pub get && cd ..
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
architecture: x64
- name: Building for ios
Expand Down
84 changes: 84 additions & 0 deletions lib/constants/app_strings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/// Talawa Custom error strings.
class TalawaErrors {
/// GraphQL error for handling: User not found.
static const String userNotFound = 'User not found';

/// GraphQL error for handling: User is not authenticated.
static const String userNotAuthenticated = 'User is not authenticated';

/// GraphQL error for handling: Email address already exists.
static const String emailAccountPresent = 'Email address already exists';

/// GraphQL error for handling: Invalid credentials.
static const String wrongCredentials = 'Invalid credentials';

/// GraphQL error for handling: Organization not found.
static const String organizationNotFound = 'Organization not found';

/// GraphQL error for handling: Access Token has expired. Please refresh session.
static const String refreshAccessTokenExpiredException =
'Access Token has expired. Please refresh session.';

/// GraphQL error for handling: Membership Request already exists.
static const String memberRequestExist = 'Membership Request already exists';

/// GraphQL error for handling: Failed to determine project ID.
static const String failedToDetermineProject =
'Failed to determine project ID: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal. Error code: ENOTFOUND';

/// Error for creating a post.
static const String postCreationFailed =
'You are offline. Failed to create post. Please try again.';

/// Error for updating a post.
static const String postUpdateFailed =
'You are offline. Failed to update post. Please try again.';

/// Error for deleting a post.
static const String postDeletionFailed =
'You are offline. Failed to delete post. Please try again.';

/// Error for creating an event.
static const String eventCreationFailed =
'You are offline. Failed to create event. Please try again.';

/// Error for updating an event.
static const String eventUpdateFailed =
'You are offline. Failed to update event. Please try again.';

/// Error for deleting an event.
static const String eventDeletionFailed =
'You are offline. Failed to delete event. Please try again.';

/// Error for sending a chat message.
static const String chatMessageSendFailed =
'You are offline. Failed to send chat message. Please try again.';

/// Error for deleting a chat message.
static const String chatMessageDeletionFailed =
'You are offline. Failed to delete chat message. Please try again.';

/// Error for updating user profile.
static const String userProfileUpdateFailed =
'You are offline. Failed to update user profile. Please try again.';

/// Error for deleting user profile.
static const String userProfileDeletionFailed =
'You are offline. Failed to delete user profile. Please try again.';

/// Error for saving user action.
static const String userActionNotSaved =
'You are offline. User action not saved.';

/// Error for login attempt when offline.
static const String youAreOfflineUnableToLogin =
'You are offline, unable to login, please try again later.';

/// Error for logout attempt when offline.
static const String youAreOfflineUnableToLogout =
'You are offline, unable to logout, please try again later.';

/// Error for signup attempt when offline.
static const String youAreOfflineUnableToSignUp =
'You are offline, unable to sign up, please try again later.';
}
51 changes: 51 additions & 0 deletions lib/enums/enums.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import 'package:hive/hive.dart';

part 'enums.g.dart';

/// Represents the state of the view.
enum ViewState {
/// The view is not doing anything.
Expand Down Expand Up @@ -69,3 +73,50 @@ enum ModalSheet {
/// Represents the modal sheet for invite.
invite
}

/// This enum defines the possible statuses for a cached user action.
///
/// It's used with Hive to store the state of user actions locally.
@HiveType(typeId: 4)
enum CachedUserActionStatus {
/// The user action is still waiting to be processed.
@HiveField(0)
pending,

/// The user action has been successfully completed.
@HiveField(1)
completed,
}

/// This enum defines the different types of cached GraphQL operations.
///
/// It's used with Hive to store information about cached queries and mutations.
@HiveType(typeId: 5)
enum CachedOperationType {
/// A GraphQL query that requires user authentication.
@HiveField(0)
gqlAuthQuery,

/// A GraphQL mutation that requires user authentication.
@HiveField(1)
gqlAuthMutation,

/// A GraphQL query that does not require user authentication.
@HiveField(2)
gqlNonAuthQuery,

/// A GraphQL mutation that does not require user authentication.
@HiveField(3)
gqlNonAuthMutation,
}

/// Enum representing the types of actions that can be performed.
enum ActionType {
/// A critical action that requires immediate attention and cannot be delayed.
critical,

/// An optimistic action that can be performed with the assumption that it will succeed.
///
/// even if the result is not immediately confirmed.
optimistic,
}
96 changes: 96 additions & 0 deletions lib/enums/enums.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions lib/exceptions/critical_action_exception.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:graphql_flutter/graphql_flutter.dart';

/// Exception thrown for critical actions that require special handling.
///
/// Extends [OperationException] to integrate with GraphQL error handling.
class CriticalActionException extends OperationException {
/// Constructor for [CriticalActionException].
///
/// Takes a [actionError] message that describes the specific error encountered.
CriticalActionException(this.actionError);

/// The error message associated with this critical action.
String actionError;

@override
String toString() => 'CriticalActionException: $actionError';
}
Loading

0 comments on commit dc25164

Please sign in to comment.