openDB static method

Future<void> openDB({
  1. 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(ChatwootContactAdapter());
    }
    if (!Hive.isAdapterRegistered(CHATWOOT_CONVERSATION_HIVE_TYPE_ID)) {
      Hive..registerAdapter(ChatwootConversationAdapter());
    }
    if (!Hive.isAdapterRegistered(CHATWOOT_MESSAGE_HIVE_TYPE_ID)) {
      Hive..registerAdapter(ChatwootMessageAdapter());
    }
    if (!Hive.isAdapterRegistered(CHATWOOT_EVENT_USER_HIVE_TYPE_ID)) {
      Hive..registerAdapter(ChatwootEventMessageUserAdapter());
    }
    if (!Hive.isAdapterRegistered(CHATWOOT_USER_HIVE_TYPE_ID)) {
      Hive..registerAdapter(ChatwootUserAdapter());
    }
  } else {
    onInitializeHive();
  }

  await PersistedChatwootContactDao.openDB();
  await PersistedChatwootConversationDao.openDB();
  await PersistedChatwootMessagesDao.openDB();
  await PersistedChatwootUserDao.openDB();
}