Skip to content

[Synchronize Contact] Store contact and fetches contact #890

Open
@nqhhdev

Description

Desc

  • If contact does not exist on the server, store it in local database (Hive)
  • Create ContactsCollectionBox
  String get _contactsBoxName => 'contacts_box';
  late CollectionBox<Map> contactsCollectionBox;
  • Create ContactHiveDatasource
abstract class ContactHiveDatasource {
  Future<void> storeContactHive(
    String clientName,
    Contact contact,
  );
}
  • Create ContactHiveRepository
abstract class ContactHiveRepository {

  Future<void> storeContactHive(
    String clientName,
    Contact contact,
  );
}
  • Create ContactHiveRepositoryImpl and ContactHiveDatasourceImpl
  • Create storeContactHive method to save contact in hive
Future<void> storeContactHive(String clientName, Contact contact) async {
    final hiveCollectionToMDatabase =
        await getIt.getAsync<HiveCollectionToMDatabase>();
    return hiveCollectionToMDatabase.contactsCollectionBox.put(
      clientName,
      contact toJson(),
    );
  }
  • Get contact from local database
  • Create getContactHive method in ContactHiveDatasource and ContactHiveRepository
abstract class ContactHiveDatasource {
  Future<List<Contact>> getContactHive(String clientName);
}
abstract class ContactHiveRepository {
  Future<List<Contact>> getContactHive(String clientName);
}
  • Create getContactHive method to get all contact from hive
Future<Contact> getContactHive(String clientName) async {
    final hiveCollectionToMDatabase =
        await getIt.getAsync<HiveCollectionToMDatabase>();
    return hiveCollectionToMDatabase.contactsCollectionBox.getAll(clientName);
  }

DoD

  • Store contact to database
  • Get contact to database

Metadata

Assignees

No one assigned

    Labels

    FT::CONTACTFeatures connected to contacts and contact listtechTechnical issues or refactoring

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions