newHomeMenu function

Future<HomeMenuModel> newHomeMenu(
  1. String appId, {
  2. bool? store,
})

Implementation

Future<HomeMenuModel> newHomeMenu(String appId, {bool? store}) async {
  var homeMenuId = homeMenuID(appId);
  var menuDefModel = await menuDefRepository(appId: appId)!.get(homeMenuId);
  if (menuDefModel == null) {
    menuDefModel = newMenuDef(appId, homeMenuId);
    await menuDefRepository(appId: appId)!.add(menuDefModel);
  }
  var homeMenuModel =
      HomeMenuModel(documentID: homeMenuId, appId: appId, menu: menuDefModel);
  if ((store != null) && (store)) {
    await homeMenuRepository(appId: appId)!.add(homeMenuModel);
  }
  return homeMenuModel;
}