openDB static method
Future<void>
openDB(
{ - void onInitializeHive()?,
})
Implementation
static Future<void> openDB({void Function()? onInitializeHive}) async {
if (onInitializeHive == null) {
await Hive.initFlutter();
if (!Hive.isAdapterRegistered(CHATWOOT_CONTACT_HIVE_TYPE_ID)) {
Hive..registerAdapter(RuutContactAdapter());
}
if (!Hive.isAdapterRegistered(CHATWOOT_CONVERSATION_HIVE_TYPE_ID)) {
Hive..registerAdapter(RuutConversationAdapter());
}
if (!Hive.isAdapterRegistered(CHATWOOT_MESSAGE_HIVE_TYPE_ID)) {
Hive..registerAdapter(RuutMessageAdapter());
}
if (!Hive.isAdapterRegistered(CHATWOOT_EVENT_USER_HIVE_TYPE_ID)) {
Hive..registerAdapter(RuutEventMessageUserAdapter());
}
if (!Hive.isAdapterRegistered(CHATWOOT_USER_HIVE_TYPE_ID)) {
Hive..registerAdapter(RuutUserAdapter());
}
} else {
onInitializeHive();
}
await PersistedRuutContactDao.openDB();
await PersistedRuutConversationDao.openDB();
await PersistedRuutMessagesDao.openDB();
await PersistedRuutUserDao.openDB();
}