getHomepage static method

Future<PageModel?> getHomepage(
  1. AppModel app,
  2. bool isBlocked,
  3. PrivilegeLevel privilegeLevel
)

Implementation

static Future<PageModel?> getHomepage(
    AppModel app, bool isBlocked, PrivilegeLevel privilegeLevel) {
  var appId = app.documentID;
  if (app.homePages == null) {
    return AccessDetermined.getPage(appId, null, alternativePageId: null);
  }
  if (isBlocked) {
    return AccessDetermined.getPage(
        appId, app.homePages!.homePageBlockedMember,
        alternativePageId: app.homePages!.homePagePublic);
  }
  if ((privilegeLevel.index >= PrivilegeLevel.ownerPrivilege.index)) {
    return AccessDetermined.getPage(appId, app.homePages!.homePageOwner,
        alternativePageId: app.homePages!.homePagePublic);
  }
  if ((privilegeLevel.index >= PrivilegeLevel.level2Privilege.index)) {
    return AccessDetermined.getPage(
        appId, app.homePages!.homePageLevel2Member,
        alternativePageId: app.homePages!.homePagePublic);
  }
  if ((privilegeLevel.index >= PrivilegeLevel.level1Privilege.index)) {
    return AccessDetermined.getPage(
        appId, app.homePages!.homePageLevel1Member,
        alternativePageId: app.homePages!.homePagePublic);
  }
  if ((privilegeLevel.index >= PrivilegeLevel.noPrivilege.index)) {
    return AccessDetermined.getPage(
        appId, app.homePages!.homePageSubscribedMember,
        alternativePageId: app.homePages!.homePagePublic);
  }
  return AccessDetermined.getPage(appId, app.homePages!.homePagePublic);
}