Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built caching support #2537

Merged
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2da9ba6
built_offline_user_actons_support
Azad99-9 Jul 24, 2024
903ebb7
fixed failing tests
Azad99-9 Jul 25, 2024
10ecbed
upgraded sdk version
Azad99-9 Jul 25, 2024
813df83
upgraded dart sdk to 3.4.4
Azad99-9 Jul 25, 2024
dd70be6
downgraded build_runner to previous version
Azad99-9 Jul 25, 2024
1b846f7
upgraded intl
Azad99-9 Jul 25, 2024
b85835d
resolved versions and upgraded sdk to 3.4.4
Azad99-9 Jul 25, 2024
e1ee411
updated workflows
Azad99-9 Jul 25, 2024
9768db5
refactored the no of lines in databasemutationfunctions
Azad99-9 Jul 25, 2024
72f193a
fixed dart format
Azad99-9 Jul 25, 2024
e7ae826
fixed run check ignore
Azad99-9 Jul 25, 2024
47463ab
fixed dart format
Azad99-9 Jul 25, 2024
e2223e9
covered some uncovered lines
Azad99-9 Jul 26, 2024
f616cac
fixed anlyze bug
Azad99-9 Jul 26, 2024
f12b98a
minor commit
Azad99-9 Jul 26, 2024
b7adb1d
Merge branch 'develop' into build_cached_user_actions
Azad99-9 Jul 27, 2024
972dc63
covered some uncovered lines
Azad99-9 Jul 27, 2024
ec2e4cf
raised code coverage
Azad99-9 Jul 27, 2024
88e4ee8
covered most of the lines
Azad99-9 Jul 27, 2024
e0a5d11
code coverage raised
Azad99-9 Jul 27, 2024
faa6fe0
code coverage fixed for all files
Azad99-9 Jul 27, 2024
1dcc161
fixed code coverage
Azad99-9 Jul 27, 2024
c7db01e
fixed code coverage
Azad99-9 Jul 27, 2024
ee92436
built mocks
Azad99-9 Jul 27, 2024
ef284f7
some minor changes
Azad99-9 Aug 1, 2024
544d1a5
built caching support for all feeds
Azad99-9 Aug 31, 2024
fa75c7d
resolved merge conflicts
Azad99-9 Aug 31, 2024
871e391
fixed failing tests
Azad99-9 Aug 31, 2024
f0603d1
Merge branch 'develop' into build_caching_support
Azad99-9 Sep 2, 2024
f7b0f47
fixed coderabbit suggestions
Azad99-9 Sep 2, 2024
a83b373
fixed format issue
Azad99-9 Sep 2, 2024
89c3ece
fixed code coverage
Azad99-9 Sep 2, 2024
6c3adf5
Merge branch 'develop' into build_caching_support
Azad99-9 Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions lib/constants/constants.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// ignore_for_file: talawa_api_doc
// ignore_for_file: talawa_good_doc_comments

import 'package:talawa/models/language/language_model.dart';

/// This file contains the prototypes of all the languages available and supported currencies.
/// This file contains the prototypes of all the supported languages and currencies used in the application.
///
/// A list of [Language] objects representing the languages supported by the application.
///
/// Each [Language] object contains the following properties:
/// * `countryCode`: The country code associated with the language.
/// * `langCode`: The language code representing the language.
/// * `langName`: The name of the language in its native script.
/// * `langSample`: A sample text phrase in the language, used for display purposes.
List<Language> languages = [
Language(
countryCode: 'US',
Expand Down Expand Up @@ -55,6 +60,10 @@ List<Language> languages = [
),
];

/// A list of supported currency codes used in the application.
///
/// Each currency code is represented as a string in the list. This list is used to ensure that the application
/// supports various currencies for transactions, conversions, or displays.
List<String> supportedCurrencies = [
'AED',
'ALL',
Expand Down Expand Up @@ -150,3 +159,33 @@ List<String> supportedCurrencies = [
'YER',
'ZAR',
];

/// A class containing static constants representing the keys used to identify Hive boxes in the application.
///
/// These keys are used to open or access specific Hive boxes, which store various types of data such as user information,
/// organization details, and cached actions.
class HiveKeys {
/// The key used to identify the Hive box that stores the current user information.
static const userBoxKey = 'currentUser';

/// The key used to identify the Hive box that stores the current organization's information.
static const orgBoxKey = 'currentOrg';

/// The key used to identify the Hive box that stores asymmetric keys for the user.
static const asymetricKeyBoxKey = 'user_keys';

/// The key used to identify the Hive box that stores plugin-related data.
static const pluginBoxKey = 'pluginBox';

/// The key used to identify the Hive box that stores URLs.
static const urlBoxKey = 'url';

/// The key used to identify the Hive box that stores the post feed data.
static const postFeedKey = 'post_feed_key';

/// The key used to identify the Hive box that stores the event feed data.
static const eventFeedKey = 'event_feed_key';

/// The key used to identify the Hive box that stores the offline action queue.
static const offlineActionQueueKey = 'offline_action_queue';
}
19 changes: 3 additions & 16 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
import 'package:quick_actions/quick_actions.dart';
import 'package:talawa/constants/quick_actions.dart';
import 'package:talawa/locator.dart';
import 'package:talawa/models/asymetric_keys/asymetric_keys.dart';
import 'package:talawa/models/organization/org_info.dart';
import 'package:talawa/models/user/user_info.dart';
import 'package:talawa/plugins/fetch_plugin_list.dart';
import 'package:talawa/router.dart' as router;
import 'package:talawa/services/hive_manager.dart';
import 'package:talawa/utils/app_localization.dart';
import 'package:talawa/view_model/base_view_model.dart';
import 'package:talawa/view_model/connectivity_view_model.dart';
Expand All @@ -26,21 +24,10 @@
WidgetsFlutterBinding.ensureInitialized();

final Directory dir = await path.getApplicationDocumentsDirectory();
Hive
..init(dir.path)
..registerAdapter(UserAdapter())
..registerAdapter(OrgInfoAdapter())
..registerAdapter(AsymetricKeysAdapter());

await Hive.openBox<User>('currentUser');
await Hive.openBox<OrgInfo>('currentOrg');
await Hive.openBox<AsymetricKeys>('user_keys');
await Hive.openBox('pluginBox');
await Hive.openBox('url');

setupLocator();
await HiveManager.initializeHive(dir: dir);

Check warning on line 28 in lib/main.dart

View check run for this annotation

Codecov / codecov/patch

lib/main.dart#L28

Added line #L28 was not covered by tests

await cacheService.initialise();
setupLocator();

Check warning on line 30 in lib/main.dart

View check run for this annotation

Codecov / codecov/patch

lib/main.dart#L30

Added line #L30 was not covered by tests

// The runApp() function takes the given Widget and makes it the root of the widget tree.
runApp(MyApp());
Expand Down
21 changes: 18 additions & 3 deletions lib/models/comment/comment_model.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// ignore_for_file: talawa_api_doc
// ignore_for_file: talawa_good_doc_comments

import 'package:hive/hive.dart';
import 'package:talawa/models/user/user_info.dart';

part 'comment_model.g.dart';

///This class returns a Comment instance.
@HiveType(typeId: 12)
class Comment {
Comment({this.text, this.createdAt, this.creator, this.post, this.likeCount});
//Creating a new Comment instance from a map structure.
Expand All @@ -23,9 +24,23 @@ class Comment {
);
}

/// The text of the comment.
@HiveField(0)
String? text;

/// The creation date of the comment.
@HiveField(1)
String? createdAt;

/// The creator of the comment.
@HiveField(2)
User? creator;

/// The post associated with the comment.
@HiveField(3)
String? post;

/// The like count of the comment.
@HiveField(4)
String? likeCount;
}
53 changes: 53 additions & 0 deletions lib/models/comment/comment_model.g.dart

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

32 changes: 29 additions & 3 deletions lib/models/events/event_model.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import 'package:hive/hive.dart';
import 'package:talawa/models/organization/org_info.dart';
import 'package:talawa/models/user/user_info.dart';

part 'event_model.g.dart';

///This class creates an event model and returns an Event instance.
@HiveType(typeId: 10)
class Event {
Event({
this.id,
Expand Down Expand Up @@ -66,59 +70,77 @@ class Event {
);
}

///Unique identifier for the event.
/// Unique identifier for the event.
@HiveField(0)
String? id;

/// The title of the event.
@HiveField(1)
String? title;

/// The description of the event.
@HiveField(2)
String? description;

/// The location of the event.
@HiveField(3)
String? location;

/// A boolean value that indicates if the event is recurring.
@HiveField(4)
bool? recurring;

/// A boolean value that indicates if the event is an all-day event.
@HiveField(5)
bool? allDay;

/// The start date of the event.
@HiveField(6)
String? startDate;

/// The end date of the event.
@HiveField(7)
String? endDate;

/// The start time of the event.
@HiveField(8)
String? startTime;

/// The end time of the event.
@HiveField(9)
String? endTime;

/// A boolean value that indicates if the event is public.
@HiveField(10)
bool? isPublic;

/// A boolean value that indicates if the user is registered for the event.
@HiveField(11)
bool? isRegistered;

/// A boolean value that indicates if the event is registerable.
@HiveField(12)
bool? isRegisterable;

/// The creator of the event.
@HiveField(13)
User? creator;

/// The organization of the event.
@HiveField(14)
OrgInfo? organization;

/// The admins of the event.
@HiveField(15)
List<User>? admins;

/// The attendees of the event.
@HiveField(16)
List<Attendee>? attendees;
}

///This class creates an attendee model and returns an Attendee instance.
@HiveType(typeId: 11)
class Attendee {
Attendee({this.id, this.firstName, this.lastName, this.image});

Expand All @@ -129,16 +151,20 @@ class Attendee {
image = json['image'] as String?;
}

///Unique identifier for the attendee.
/// Unique identifier for the attendee.
@HiveField(0)
String? id;

/// The first name of the attendee.
@HiveField(1)
String? firstName;

/// The last name of the attendee.
@HiveField(2)
String? lastName;

/// The image of the attendee.
/// The image URL of the attendee.
@HiveField(3)
String? image;

/// Converts the Attendee instance to a map structure..
Expand Down
Loading
Loading