Facebook
From Insensitive Agouti, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 66
  1. import React from 'react';
  2. import { Animated, ScrollView, FlatList, Platform, Text, View, TouchableOpacity, Image, Dimensions, ActivityIndicator } from 'react-native';
  3. import { SafeAreaView } from 'react-native-safe-area-context';
  4. import styles from '../styles/Content';
  5. import drawerStyles from '../styles/DrawerMenu';
  6. import CustomIcons from '../components/CustomIcon';
  7. import ContentListView from '../components/ContentListView';
  8. import EmptyScreen from '../components/EmptyScreen';
  9. import Chip from '../components/Chip';
  10. import EStyleSheet from 'react-native-extended-stylesheet';
  11. import DrawerLayout from 'react-native-drawer-layout';
  12. import { translate } from '../locales/i18n';
  13. import Spinner from 'react-native-spinkit';
  14. import config from '../config/config';
  15. import staticConfig from '../config/staticConfig';
  16. import * as conProvider from '../utils/ConProvider';
  17. import * as colProvider from '../utils/ColProvider';
  18. import * as insProvider from '../utils/InsProvider';
  19. import * as varProvider from '../utils/VarProvider';
  20. import * as jaProvider from '../utils/JAProvider';
  21. import * as connection from '../utils/Connection';
  22. import * as apiProvider from '../utils/ApiProvider';
  23. import * as storageProvider from '../utils/StorageProvider';
  24. import * as analyticsProvider from '../utils/AnalyticsProvider';
  25. import * as setProvider from '../utils/SetProvider';
  26. import * as notProvider from '../utils/NotProvider';
  27. import screenNames from '../config/screenNames';
  28. import Toast from '@remobile/react-native-toast';
  29. import RNFetchBlob from 'rn-fetch-blob';
  30. import NativeReachabilityModule from '../components/NativeReachabilityModule';
  31. import VPNModule from '../components/VPNModule';
  32. import ArticleLoader from '../components/ArticleLoader';
  33. import Modal from 'react-native-modal';
  34. import AsyncStorage from '@react-native-async-storage/async-storage';
  35. import imageJson from '../config/imageJson';
  36. import guideImageJson from '../config/guideImageJson';
  37. import GuideView from '../components/GuideView';
  38. import ActionSheet from '../components/ActionSheet';
  39.  
  40. var contentList, currentType, noMoreData, isInfiniteOn, currentTitle = "", activeType, favIndex = 0, fromDidMount, modalObserver, conVPNObserver, menuItemId;
  41. var typeList = [];
  42. var pagingCount = config.contentPagingCount;
  43. var cloneIt, alreadyLoaded;
  44. var currentRandomId, currentRandomTypeId, isRootCall, isListFromGraph;
  45. var shouldShowJournalDetail, modalWidth, modalHeight, multiUrlsList = [], graphError;
  46. var addVPNPopup = false;
  47.  
  48. export default class Content extends React.Component {
  49.  
  50.   constructor(props) {
  51.     super(props);
  52.  
  53.     this.state = {
  54.       isCardView: false,
  55.       contentList: [],
  56.       footerLoading: false,
  57.       contentLoading: true,
  58.       contentLength: 0,
  59.       errorModal: false,
  60.       pubFilters: [],
  61.       refreshTypes: false,
  62.       isDrawerOn: false,
  63.       drawerLockMode: "locked-closed",
  64.       showGuide: false,
  65.       multiUrlsView: false,
  66.       isConnected: connection.isConnectedFun(),
  67.       isVPNConfigAccepted: true,
  68.       isVPNOptional: true
  69.     };
  70.     graphError = "";
  71.     contentList = [];
  72.     isListFromGraph = false;
  73.     currentType = null;
  74.     activeType = null;
  75.     currentTitle = "";
  76.     menuItemId = "";
  77.     typeList = [];
  78.     alreadyLoaded = true;
  79.     isInfiniteOn = false;
  80.     varProvider.drawerLockMode = "locked-closed";
  81.     addVPNPopup = false;
  82.  
  83.     this.openMenu = this.openMenu.bind(this);
  84.     this.callbackFun = this.callbackFun.bind(this);
  85.     this.buttonCallback = this.buttonCallback.bind(this);
  86.     this.rootButtonCallback = this.rootButtonCallback.bind(this);
  87.     this.callbackFavorite = this.callbackFavorite.bind(this);
  88.     this.removeItem = this.removeItem.bind(this);
  89.     this.openContent = this.openContent.bind(this);
  90.     this.openVpnInfo = this.openVpnInfo.bind(this);
  91.     this.callbackVpnInfo = this.callbackVpnInfo.bind(this);
  92.     this.favoriteContent = this.favoriteContent.bind(this);
  93.     this.viewDetails = this.viewDetails.bind(this);
  94.     this.successFetchingImage = this.successFetchingImage.bind(this)
  95.     this.errorFetchingImage = this.errorFetchingImage.bind(this)
  96.     this.insertIntoTypeList = this.insertIntoTypeList.bind(this)
  97.     this.insertIntoContentList = this.insertIntoContentList.bind(this)
  98.     this.initMaxHeight = this.initMaxHeight.bind(this)
  99.     this.shakeAnimation = new Animated.Value(0)
  100.   }
  101.  
  102.   static navigationOptions = ({ navigation, route }) => {
  103.     return {
  104.       headerShown: false
  105.     }
  106.   }
  107.  
  108.   componentDidMount() {
  109.     fromDidMount = true;
  110.     varProvider.currentScreen = screenNames.Content
  111.     this.initMaxHeight();
  112.     Dimensions.addEventListener("change", this.initMaxHeight);
  113.     this.rootButtonCallback();
  114.  
  115.     AsyncStorage.getItem("shouldShowJournalDetail").then((value) => {
  116.       shouldShowJournalDetail = value;
  117.     })
  118.  
  119.     setProvider.showGuide("iseResourcesGuideShown", screenNames.Content).then((res) => {
  120.       if (res) {
  121.         this.setState({ showGuide: true });
  122.       }
  123.       else {
  124.         this.checkIfVPNCreated();
  125.       }
  126.     })
  127.  
  128.     varProvider.connectionObserver.subscribe(() => {
  129.       let isConnected = connection.isConnectedFun();
  130.       if (!isConnected) {
  131.         this.showNoInternetError();
  132.       }
  133.  
  134.       if (isConnected && this.state.errorModal)
  135.         this.rootButtonCallback();
  136.  
  137.       this.setState({
  138.         isConnected: isConnected,
  139.         refreshTypes: !this.state.refreshTypes
  140.       });
  141.     });
  142.  
  143.     modalObserver = varProvider.modalClosedObserver.subscribe((data) => {
  144.       if (varProvider.currentScreen === screenNames.Content && data.other) {
  145.         if (this.state.permissionModal || this.state.showGuide || this.state.multiUrlsView) {
  146.           this.setState({
  147.             permissionModal: false,
  148.             showGuide: false
  149.           });
  150.           this.closeActionSheetModal()
  151.         }
  152.         if (varProvider.modalClosedObserver) {
  153.           let resJson = {
  154.             "home": true,
  155.             "other": false,
  156.             "screen": screenNames.Content,
  157.           }
  158.           varProvider.modalClosedObserver.next(resJson);
  159.         }
  160.       }
  161.     })
  162.  
  163.     conVPNObserver = varProvider.vpnObserver.subscribe((res) => {
  164.       this.setState({
  165.         isVPNConfigAccepted: res
  166.       })
  167.     })
  168.  
  169.     this._unsubscribe = this.props.navigation.addListener('focus', () => {
  170.       this.isFocused();
  171.     });
  172.   }
  173.  
  174.   componentWillUnmount() {
  175.     modalObserver.unsubscribe();
  176.     conVPNObserver.unsubscribe();
  177.     this._unsubscribe();
  178.   }
  179.  
  180.   isFocused() {
  181.     const { params } = this.props.route;
  182.     if (params) {
  183.       //console.log("params::", params);
  184.       // [deep link] if contentType is received from params, then set it as a active biblio type and load content list
  185.       if (menuItemId != params?.menuItemId) { //this condition handle for if user have clicked or received same deeplink url
  186.         if (params?.contentType) {
  187.           currentType = params?.contentType;
  188.           menuItemId = params?.menuItemId;
  189.           currentTitle = params?.cTitle;
  190.         }
  191.         //deeplink use case: when user have already text deeplink tab active and another deeplink with text or without text will come then we'll clear the filters before.
  192.         var tempFilters = this.state.pubFilters;
  193.         tempFilters?.map((item) => {
  194.           item.active = false;
  195.         });
  196.  
  197.  
  198.         // [deep link] if searchText is received from params, then set it as a active filter and load content list accordingly
  199.         if (currentType == params?.contentType && params?.searchText) {
  200.           let originalSearchText = params.searchText;
  201.           let trimmedSearchText = originalSearchText.trim();
  202.           let filterJson = [
  203.             {
  204.               "active": true,
  205.               "chipTitle": 'Search text: "' + originalSearchText + '"',
  206.               "value": trimmedSearchText,
  207.               "originalSearchText": originalSearchText
  208.             }
  209.           ];
  210.           this.setState({ pubFilters: filterJson })
  211.         }
  212.       }
  213.     }
  214.     varProvider.currentScreen = currentType ? currentType : screenNames.Content;
  215.     if (varProvider.isContentTabChanged) {
  216.       if (!this.state.showGuide && !fromDidMount) {
  217.         this.checkIfVPNCreated();
  218.       }
  219.     }
  220.     fromDidMount = false;
  221.  
  222.     AsyncStorage.getItem("contentUpdate").then((value) => {
  223.       let isTabChanged = varProvider.isContentTabChanged;
  224.       if (value == "true") {
  225.         this.drawer.closeDrawer();
  226.         AsyncStorage.setItem("contentUpdate", "false");
  227.         if (!alreadyLoaded) {
  228.           this.rootButtonCallback();
  229.           currentType = null;
  230.         }
  231.       } else {
  232.  
  233.         if (varProvider.isContentTabChanged) {
  234.           varProvider.isContentTabChanged = false;
  235.           //don't call when component will mount called
  236.           if (!alreadyLoaded) {
  237.             //console.log("alreadyLoaded bgGetContent");
  238.             this.bgGetContent();
  239.           }
  240.         }
  241.       }
  242.       alreadyLoaded = false;
  243.  
  244.       if (isTabChanged) {
  245.         this.logScreenViewEvent(true);
  246.         if (currentType) {
  247.           this.logScreenViewEvent(false);
  248.         }
  249.       }
  250.     });
  251.   }
  252.  
  253.   initMaxHeight() {
  254.     var sheight = Dimensions.get('window').height;
  255.     var swidth = Dimensions.get('window').width;
  256.     if (sheight < 480) {
  257.       modalHeight = 250;
  258.     }
  259.     else {
  260.       modalHeight = sheight / 2;
  261.     }
  262.  
  263.     if (swidth < 480) {
  264.       modalWidth = "100%";
  265.     }
  266.     else if (swidth < 920) {
  267.       modalWidth = "70%";
  268.     }
  269.     else {
  270.       modalWidth = "60%";
  271.     }
  272.     this.setState({ refresh: !this.state.refresh });
  273.   }
  274.  
  275.   logScreenViewEvent(isFirstTime) {
  276.     if (varProvider.lastTabName != currentType) {
  277.       var openScreen = isFirstTime ? screenNames.Content : currentType;
  278.       varProvider.currentScreen = openScreen;
  279.       let screenViewJson = {
  280.         "name": openScreen,
  281.         "previous": varProvider.lastTabName
  282.       };
  283.       analyticsProvider.logAnalyticsJson("ScreenView", screenViewJson);
  284.       varProvider.lastTabName = openScreen;
  285.     }
  286.   }
  287.  
  288.   startShake = () => {
  289.     Animated.sequence([
  290.       Animated.timing(this.shakeAnimation, { toValue: 10, duration: 100, useNativeDriver: true }),
  291.       Animated.timing(this.shakeAnimation, { toValue: -10, duration: 100, useNativeDriver: true }),
  292.       Animated.timing(this.shakeAnimation, { toValue: 10, duration: 100, useNativeDriver: true }),
  293.       Animated.timing(this.shakeAnimation, { toValue: 0, duration: 100, useNativeDriver: true })
  294.     ]).start();
  295.   }
  296.  
  297.   async checkIfVPNCreated() {
  298.     let aOptionalProxy = await storageProvider.getItem("optionalProxy");
  299.     if (aOptionalProxy == "false") {
  300.       varProvider.isVPNOptional = true;
  301.     }
  302.     // if vpn is mandatory then only check and configure vpn
  303.     if (!varProvider.isVPNOptional) {
  304.       if (Platform.OS == "ios") {
  305.         var isVpnCreated = await NativeReachabilityModule.checkIfVPNCreated();
  306.         if (isVpnCreated) {
  307.           AsyncStorage.getItem("isVPNLogged").then((isLogged) => {
  308.             if (isLogged != "true") {
  309.               this.logVPNEvent(true);
  310.               AsyncStorage.setItem("isVPNLogged", "true");
  311.             }
  312.           });
  313.           conProvider.updateProxyDetailsForIos(false);
  314.           this.setState({
  315.             isVPNConfigAccepted: true
  316.           });
  317.         } else {
  318.           // vpn analytics log
  319.           this.logVPNEvent(false);
  320.           this.setState({
  321.             permissionModal: true
  322.           });
  323.         }
  324.       } else {
  325.         if (varProvider.enableProxy) {
  326.           var isVPNConfigured = await VPNModule.isVPNConfigured();
  327.           // console.log("check if vpn created: " + isVPNConfigured);
  328.           if (isVPNConfigured) {
  329.             AsyncStorage.getItem("isVPNLogged").then((isLogged) => {
  330.               if (isLogged != "true") {
  331.                 this.logVPNEvent(true);
  332.                 AsyncStorage.setItem("isVPNLogged", "true");
  333.               }
  334.             });
  335.             conProvider.updateProxyDetailsForAndroid(false);
  336.             this.setState({
  337.               isVPNConfigAccepted: true
  338.             });
  339.           } else {
  340.             // vpn analytics log
  341.             this.logVPNEvent(false);
  342.             this.setState({
  343.               permissionModal: true
  344.             });
  345.           }
  346.         }
  347.       }
  348.     }
  349.  
  350.     this.setState({
  351.       isVPNOptional: varProvider.isVPNOptional
  352.     });
  353.   }
  354.  
  355.   logVPNEvent(isCreated) {
  356.     let vpnJson = {
  357.       "isConfigured": isCreated ? "true" : "false"
  358.     };
  359.     analyticsProvider.logAnalyticsJson("VPN", vpnJson);
  360.   }
  361.  
  362.   rootButtonCallback() {
  363.     // console.log("rootButtonCallback");
  364.     graphError = ""
  365.     contentList = [];
  366.     this.setState({
  367.       contentLoading: true,
  368.       contentLength: 0,
  369.       refresh: !this.state.refresh,
  370.       pubFilters: [],
  371.       refreshTypes: false,
  372.       accessDenied: false,
  373.       errorModal: false,
  374.       drawerLockMode: "unlocked",
  375.       isButton: false,
  376.       errorLoading: false
  377.     });
  378.     varProvider.drawerLockMode = "unlocked";
  379.     this.startProcess();
  380.   }
  381.  
  382.   buttonCallback() {
  383.     if (isRootCall) {
  384.       isRootCall = false;
  385.       this.rootButtonCallback();
  386.     } else {
  387.       graphError = ""
  388.       this.setState({
  389.         contentLoading: true,
  390.         contentLength: 0,
  391.         refreshTypes: false,
  392.         accessDenied: false,
  393.         errorModal: false,
  394.         drawerLockMode: "unlocked",
  395.         isButton: false,
  396.         errorLoading: false
  397.       });
  398.       varProvider.drawerLockMode = "unlocked";
  399.       var tempFilters = this.state.pubFilters;
  400.       this.callbackFun(tempFilters);
  401.     }
  402.   }
  403.  
  404.   bgGetContent() {
  405.     this.startProcess();
  406.   }
  407.   // when internet is not connnected , the button press from errorModal will go to collection for saved actricle
  408.   gotoCollection = () => {
  409.     const { navigate } = this.props.navigation;
  410.     navigate('Collections');
  411.   }
  412.  
  413.   //first check if email is verified or not
  414.   startProcess() {
  415.     if (connection.isConnectedFun()) {
  416.       insProvider.getUserProfile().then(() => {
  417.         //checking user status
  418.         this.checkUserStatus();
  419.       }).catch((error) => {
  420.         isRootCall = true;
  421.         this.contentError(error, 0);
  422.         this.offlineChecks(true);
  423.       });
  424.     } else {
  425.       //no internet. so, get the value of user status from local storage
  426.       this.offlineChecks(false);
  427.     }
  428.   }
  429.  
  430.   //get userstatus and accordingly show appropriate message
  431.   checkUserStatus() {
  432.     // console.log("check user status function");
  433.     AsyncStorage.multiGet(["userStatus", "instituteName"]).then((data) => {
  434.       // console.log("asyncstorage multiget");
  435.       // console.log(data);
  436.       var userStatus = data[0][1];
  437.       var instituteName = data[1][1];
  438.       var msg, imagePath;
  439.       imagePath = imageJson.pending_approval;
  440.       if (userStatus == "APPROVED") {
  441.         this.startLoadingContent();
  442.       }
  443.       else if (userStatus == "BLOCKED") {
  444.         msg = translate("USER_ACCOUNT_BLOCKED_ERROR_TITLE", { instituteName: instituteName }) + " " + translate("USER_ACCOUNT_BLOCKED_E_RESOURCE_ERROR_DESCRIPTION");
  445.         this.showError(msg, imagePath);
  446.       }
  447.       else if (userStatus == "ARCHIVED") {
  448.         msg = translate("USER_ACCOUNT_ARCHIVED_ERROR_TITLE", { instituteName: instituteName }) + " " + translate("USER_ACCOUNT_ARCHIVED_E_RESOURCE_ERROR_DESCRIPTION");
  449.         this.showError(msg, imagePath);
  450.       }
  451.       else if (userStatus == "REJECTED") {
  452.         msg = translate("USER_ACCOUNT_REJECTED_ERROR_TITLE", { instituteName: instituteName }) + " " + translate("USER_ACCOUNT_REJECTED_E_RESOURCE_ERROR_DESCRIPTION");
  453.         this.showError(msg, imagePath);
  454.       }
  455.       else if (userStatus == "PENDING") {
  456.         msg = translate("USER_ACCOUNT_PENDING_ERROR_TITLE", { instituteName: instituteName }) + " " + translate("USER_ACCOUNT_PENDING_E_RESOURCE_ERROR_DESCRIPTION");
  457.         this.showError(msg, imagePath);
  458.       }
  459.       else if (userStatus == "EXPIRED") {
  460.         msg = translate("USER_ACCOUNT_EXPIRED_ERROR_TITLE", { instituteName: instituteName }) + " " + translate("USER_ACCOUNT_EXPIRED_E_RESOURCE_ERROR_DESCRIPTION");
  461.         this.showError(msg, imagePath);
  462.       }
  463.       else if (userStatus == "REVOKED") {
  464.         msg = translate("USER_ACCOUNT_REVOKED_ERROR_TITLE", { instituteName: instituteName }) + " " + translate("USER_ACCOUNT_REVOKED_E_RESOURCE_ERROR_DESCRIPTION");
  465.         this.showError(msg, imagePath);
  466.       }
  467.     });
  468.   }
  469.  
  470.   offlineChecks(isError) {
  471.     AsyncStorage.multiGet(["userStatus", "verifyEmail"]).then((data) => {
  472.       var userStatus = data[0][1];
  473.       var verifyEmail = (data[1][1] == "true");
  474.  
  475.       if (userStatus && verifyEmail) {
  476.         //if email is verified
  477.         this.offlineUserStatusCheck(userStatus);
  478.       } else {
  479.         //if no value found for verified email or value is false
  480.         //and if offline
  481.         //show no internet message on full screen
  482.         if (isError) {
  483.           //this function is called when some error has occured in fetching either userprofile
  484.         } else {
  485.           this.showNoInternetError();
  486.         }
  487.       }
  488.     });
  489.   }
  490.  
  491.   showNoInternetError() {
  492.     if (this.drawer)
  493.       this.drawer.closeDrawer();
  494.     var msg = translate("INTERNET_EMPTY");
  495.     var imagePath = imageJson.no_internet;
  496.     var bottomText = translate("INTERNET_EMPTY_DATA1");
  497.     graphError = ""
  498.     this.setState({
  499.       accessDenied: true,
  500.       deniedMessage: msg,
  501.       contentLoading: false,
  502.       contentLength: 0,
  503.       errorModal: true,
  504.       drawerLockMode: "locked-closed",
  505.       imagePath: imagePath,
  506.       isButton: true,
  507.       bottomText: bottomText,
  508.       errorLoading: false,
  509.       multiUrlsView: false
  510.     });
  511.     varProvider.drawerLockMode = "locked-closed";
  512.   }
  513.  
  514.   //show appropriate message according to user status
  515.   offlineUserStatusCheck(userStatus) {
  516.     var msg, imagePath;
  517.     imagePath = imageJson.pending_approval;
  518.     if (userStatus == "APPROVED") {
  519.       this.startLoadingContent();
  520.     }
  521.     else if (userStatus == "BLOCKED") {
  522.       msg = translate("USER_ACCOUNT_BLOCKED_ERROR_TITLE", { instituteName: varProvider.currentInstituteName }) + " " + translate("USER_ACCOUNT_BLOCKED_E_RESOURCE_ERROR_DESCRIPTION");
  523.       this.showError(msg, imagePath);
  524.     }
  525.     else if (userStatus == "ARCHIVED") {
  526.       msg = translate("USER_ACCOUNT_ARCHIVED_ERROR_TITLE", { instituteName: varProvider.currentInstituteName }) + " " + translate("USER_ACCOUNT_ARCHIVED_E_RESOURCE_ERROR_DESCRIPTION");
  527.       this.showError(msg, imagePath);
  528.     }
  529.     else if (userStatus == "REJECTED") {
  530.       msg = translate("USER_ACCOUNT_REJECTED_ERROR_TITLE", { instituteName: varProvider.currentInstituteName }) + " " + translate("USER_ACCOUNT_REJECTED_E_RESOURCE_ERROR_DESCRIPTION");
  531.       this.showError(msg, imagePath);
  532.     }
  533.     else if (userStatus == "PENDING") {
  534.       msg = translate("USER_ACCOUNT_PENDING_ERROR_TITLE", { instituteName: varProvider.currentInstituteName }) + " " + translate("USER_ACCOUNT_PENDING_E_RESOURCE_ERROR_DESCRIPTION");
  535.       this.showError(msg, imagePath);
  536.     }
  537.     else if (userStatus == "EXPIRED") {
  538.       msg = translate("USER_ACCOUNT_EXPIRED_ERROR_TITLE", { instituteName: varProvider.currentInstituteName }) + " " + translate("USER_ACCOUNT_EXPIRED_E_RESOURCE_ERROR_DESCRIPTION");
  539.       this.showError(msg, imagePath);
  540.     }
  541.     else if (userStatus == "REVOKED") {
  542.       msg = translate("USER_ACCOUNT_REVOKED_ERROR_TITLE", { instituteName: varProvider.currentInstituteName }) + " " + translate("USER_ACCOUNT_REVOKED_E_RESOURCE_ERROR_DESCRIPTION");
  543.       this.showError(msg, imagePath);
  544.     }
  545.   }
  546.  
  547.   startLoadingContent() {
  548.     //get menu item list
  549.     this.getMenuItemsList().then((data) => {
  550.     }).catch((error) => {
  551.       if (connection.isConnectedFun()) {
  552.         this.contentError(error, 0);
  553.       } else {
  554.         this.showNoInternetError();
  555.       }
  556.     });
  557.   }
  558.  
  559.   insertIntoContentList(data, tempJson, localRandomId, isGraph) {
  560.     console.log("insertIntoContentList==========", data?.length, tempJson, localRandomId, isGraph);
  561.     if (localRandomId == currentRandomId) {
  562.       if (tempJson.type == currentType) {
  563.         this.contentSuccessPush(data, tempJson, isGraph);
  564.       }
  565.     } else {
  566.       console.log("insertIntoContentList else==========",);
  567.     }
  568.     setTimeout(() => {
  569.       isInfiniteOn = false;
  570.     }, 400);
  571.   }
  572.  
  573.   //load institute content
  574.   loadContentList(tempJson) {
  575.     //console.log("loadContentList=================", tempJson);
  576.     currentRandomId = apiProvider.generateUUID();
  577.     var localRandomId = currentRandomId;
  578.  
  579.     if (tempJson.type == staticConfig.favorite) {
  580.       //if filter is applied then directly get the result via graph query
  581.       if (!tempJson.isFilter) {
  582.         this.getContentSql(tempJson, localRandomId).then(() => {
  583.           this.getFavContentGraph(tempJson, localRandomId);
  584.         });
  585.       } else {
  586.         this.getFavContentGraph(tempJson, localRandomId);
  587.       }
  588.     }
  589.     else if (tempJson.type == staticConfig.customInstituteContent || tempJson.type == staticConfig.customLink) {
  590.       if (!tempJson.isFilter) {
  591.         this.getContentSql(tempJson, localRandomId).then(() => {
  592.           this.getContentItemsofMenuItemforUser(tempJson, localRandomId);
  593.         });
  594.       } else {
  595.         this.getContentItemsofMenuItemforUser(tempJson, localRandomId);
  596.       }
  597.     }
  598.     else {
  599.       //if filter is applied then directly get the result via graph query
  600.       if (!tempJson.isFilter) {
  601.         this.getContentSql(tempJson, localRandomId).then(() => {
  602.           //console.log("getContentGraph1", tempJson, localRandomId);
  603.           this.getContentGraph(tempJson, localRandomId);
  604.         });
  605.       } else {
  606.         // console.log("getContentGraph2");
  607.         this.getContentGraph(tempJson, localRandomId);
  608.       }
  609.     }
  610.   }
  611.  
  612.   getContentSql(tempJson, localRandomId) {
  613.     return new Promise((resolve) => {
  614.       conProvider.getContentSql(tempJson).then((data) => {
  615.  
  616.         if (data.length > 0) {
  617.           console.log("getContentSql", data?.length)
  618.           this.insertIntoContentList(data, tempJson, localRandomId, false);
  619.         }
  620.         resolve();
  621.       }).catch((error) => {
  622.         resolve();
  623.         console.log("getContentSql", error)
  624.       });
  625.     });
  626.   }
  627.  
  628.   getFavContentGraph(tempJson, localRandomId) {
  629.     conProvider.getFavContentListGraph(tempJson).then((data) => {
  630.       console.log("get fav content list then");
  631.       this.insertIntoContentList(data, tempJson, localRandomId, true)
  632.  
  633.     }).catch((error) => {
  634.       // console.log("get fav content list catch");
  635.       // console.log(error);
  636.       if (localRandomId == currentRandomId) {
  637.         if (tempJson.type == currentType) {
  638.           if (error == "ACCESSDENIED_EXPIRY") {
  639.             var msg = translate("USER_ACCOUNT_EXPIRED_ERROR_TITLE", { instituteName: varProvider.currentInstituteName }) + " " + translate("USER_ACCOUNT_EXPIRED_E_RESOURCE_ERROR_DESCRIPTION");
  640.             var imagePath = imageJson.pending_approval;
  641.             this.showError(msg, imagePath);
  642.           } else {
  643.             this.contentError(error, tempJson.skip);
  644.           }
  645.         }
  646.       }
  647.       isInfiniteOn = false;
  648.     });
  649.   }
  650.  
  651.   getContentGraph(tempJson, localRandomId) {
  652.     console.log("getContentGraph", tempJson, localRandomId);
  653.     conProvider.getContentListGraph(tempJson).then((data) => {
  654.       this.insertIntoContentList(data, tempJson, localRandomId, true)
  655.       console.log("getContentGraph get content list then", data?.length, tempJson, localRandomId, currentRandomTypeId);
  656.       //  console.log(data);
  657.     }).catch((error) => {
  658.       // console.log("get content list catch");
  659.       // console.log(error);
  660.       if (localRandomId == currentRandomId) {
  661.         if (tempJson.type == currentType) {
  662.           if (error == "ACCESSDENIED_EXPIRY") {
  663.             var msg = translate("USER_ACCOUNT_EXPIRED_ERROR_TITLE", { instituteName: varProvider.currentInstituteName }) + " " + translate("USER_ACCOUNT_EXPIRED_E_RESOURCE_ERROR_DESCRIPTION");
  664.             var imagePath = imageJson.pending_approval;
  665.             this.showError(msg, imagePath);
  666.           } else {
  667.             this.contentError(error, tempJson.skip);
  668.           }
  669.         }
  670.       }
  671.       isInfiniteOn = false;
  672.     });
  673.   }
  674.  
  675.   getContentItemsofMenuItemforUser(tempJson, localRandomId) {
  676.     conProvider.getContentItemsofMenuItemforUser(tempJson).then((data) => {
  677.       this.insertIntoContentList(data, tempJson, localRandomId, true)
  678.       //  console.log(data);
  679.     }).catch((error) => {
  680.       // console.log("get content list catch");
  681.       // console.log(error);
  682.       if (localRandomId == currentRandomId) {
  683.         if (tempJson.type == currentType) {
  684.           if (error == "ACCESSDENIED_EXPIRY") {
  685.             var msg = translate("USER_ACCOUNT_EXPIRED_ERROR_TITLE", { instituteName: varProvider.currentInstituteName }) + " " + translate("USER_ACCOUNT_EXPIRED_E_RESOURCE_ERROR_DESCRIPTION");
  686.             var imagePath = imageJson.pending_approval;
  687.             this.showError(msg, imagePath);
  688.           } else {
  689.             this.contentError(error, tempJson.skip);
  690.           }
  691.         }
  692.       }
  693.       isInfiniteOn = false;
  694.     });
  695.   }
  696.  
  697.   //process content data
  698.   contentSuccessPush(data, tempJson, isGraph) {
  699.     console.log("contentSuccessPush::::::", data?.length, tempJson, isGraph);
  700.     if (data.length < 30 && isGraph) {
  701.       noMoreData = true;
  702.     }
  703.     var loadedId = [];
  704.     if (currentType == staticConfig.customLink || currentType == staticConfig.favorite) {
  705.       for (var k = 0; k < contentList.length; k++) {
  706.         if (contentList[k].isFetched) {
  707.           loadedId.push(contentList[k].id);
  708.         }
  709.       }
  710.     }
  711.     const { params } = this.props.route;
  712.     console.log("tempJson.skip", params);
  713.     if (tempJson.skip == 0) {
  714.       console.log("tempJson.skip");
  715.       contentList = [];
  716.     }
  717.     for (var i = 0; i < data.length; i++) {
  718.       var initials = data[i].title.charAt(0).toUpperCase();
  719.       var isFetched = false;
  720.       if (loadedId.length != 0) {
  721.         if (loadedId.indexOf(data[i].id) != -1) {
  722.           isFetched = true;
  723.         }
  724.       }
  725.  
  726.       var type = data[i].type;
  727.       var issn = data[i].issn;
  728.       var eissn = data[i].eissn;
  729.       var cid = data[i].contentId;
  730.       var url = data[i].url;
  731.       var libCoverImage = data[i].libCoverImage;
  732.       var contentUpdatedAt = data[i].contentUpdatedAt
  733.       var contentImage = this.loadContentImageFast(issn, eissn, type, cid, libCoverImage, contentUpdatedAt);
  734.       var phImage = conProvider.getBgContentImage(type, url);
  735.       var smallImage = conProvider.getContentImageSmall(type, data);
  736.       var bgColor = conProvider.getContentBg(type);
  737.       var multiUrls = data[i].multiUrls ? JSON.parse(data[i].multiUrls) : null
  738.       contentList.push({
  739.         "id": data[i].id,
  740.         "title": data[i].title,
  741.         "libDescription": data[i].libDescription,
  742.         "url": url,
  743.         "type": type,
  744.         "publisherName": data[i].publisherName,
  745.         "isFavorite": data[i].isFavorite,
  746.         "image": contentImage,
  747.         "phImage": phImage,
  748.         "smallImage": smallImage,
  749.         "isFetched": isFetched,
  750.         "issn": issn,
  751.         "eissn": eissn,
  752.         "initials": initials,
  753.         "bgColor": bgColor,
  754.         "multiUrls": multiUrls,
  755.         "customInsContentId": data[i].customInsContentId,
  756.         "contentType": data[i].contentType,
  757.       });
  758.     }
  759.  
  760.     isListFromGraph = isGraph;
  761.     console.log("contentList::===", contentList?.length);
  762.     graphError = ""
  763.     this.setState({
  764.       refresh: !this.state.refresh,
  765.       contentLoading: false,
  766.       footerLoading: false,
  767.       errorLoading: false,
  768.       contentLength: contentList.length,
  769.       accessDenied: false,
  770.       errorModal: false,
  771.       drawerLockMode: "unlocked"
  772.     });
  773.     varProvider.drawerLockMode = "unlocked";
  774.   }
  775.  
  776.   //error to show when content fetching fails
  777.   contentError(error, skipVal) {
  778.     if (skipVal > pagingCount - 1) {
  779.       //error while fetching next 30 article
  780.       graphError = ""
  781.       this.setState({ contentLoading: false, footerLoading: false, errorLoading: false, contentLength: contentList.length });
  782.     } else {
  783.       connection.getGraphError(error).then((data) => {
  784.         graphError = data
  785.         this.setState({
  786.           errorLoading: true,
  787.           contentLoading: false,
  788.           footerLoading: false,
  789.           contentLength: contentList.length,
  790.           accessDenied: false,
  791.           errorModal: false,
  792.           drawerLockMode: "unlocked"
  793.         });
  794.       })
  795.       varProvider.drawerLockMode = "unlocked";
  796.     }
  797.   }
  798.  
  799.   errorFetchingImage(contentItem) {
  800.     for (var i = 0; i < contentList.length; i++) {
  801.       if (contentList[i].id == contentItem.id) {
  802.         contentList[i].isFetched = false;
  803.         break;
  804.       }
  805.     }
  806.     this.setState({ refresh: !this.state.refresh });
  807.   }
  808.  
  809.   successFetchingImage(contentItem) {
  810.     for (var i = 0; i < contentList.length; i++) {
  811.       if (contentList[i].id == contentItem.id) {
  812.         contentList[i].isFetched = true;
  813.         break;
  814.       }
  815.     }
  816.     this.setState({ refresh: !this.state.refresh });
  817.   }
  818.  
  819.   loadContentImageFast(issn, eissn, contentType, cid, libCoverImage, contentUpdatedAt) {
  820.     var url;
  821.     if (contentType == staticConfig.database) {
  822.       if (libCoverImage === null) {
  823.         url = config.coverUrl + contentType.toLowerCase() + "/" + cid.concat(contentUpdatedAt ? "?v=" + contentUpdatedAt : "");
  824.       } else {
  825.         url = libCoverImage;
  826.       }
  827.     }
  828.     else if (contentType == staticConfig.link) {
  829.       url = config.s3AppSettingBucket + "institute/" + varProvider.currentInstituteId + "/contentItem/contentitem_" + cid;
  830.     }
  831.     else {
  832.       if (issn) {
  833.         url = config.coverUrl + contentType.toLowerCase() + "/" + issn + ".jpg".concat(contentUpdatedAt ? "?v=" + contentUpdatedAt : "");
  834.       } else if (eissn) {
  835.         url = config.coverUrl + contentType.toLowerCase() + "/" + eissn + ".jpg".concat(contentUpdatedAt ? "?v=" + contentUpdatedAt : "");
  836.       } else {
  837.         url = conProvider.getContentImage(contentType);
  838.       }
  839.     }
  840.  
  841.     return url;
  842.   }
  843.  
  844.   loadContentImage(contentItem) {
  845.     // console.log(contentItem);
  846.     var path = RNFetchBlob.fs.dirs.DocumentDir + "/" + contentItem.id + ".jpg";
  847.     RNFetchBlob.fs.exists(path).then((exist) => {
  848.       // console.log("content image exist: " + exist);
  849.       if (exist) {
  850.         for (var i = 0; i < contentList.length; i++) {
  851.           if (contentList[i].id == contentItem.id) {
  852.             contentList[i].image = "file://" + path;
  853.             break;
  854.           }
  855.         }
  856.         this.setState({ refresh: !this.state.refresh });
  857.       } else {
  858.         var issnOrIsbn;
  859.         if (contentItem.issn) {
  860.           issnOrIsbn = contentItem.issn;
  861.           this.writeContentImage(contentItem, issnOrIsbn, true);
  862.         } else if (contentItem.eissn) {
  863.           issnOrIsbn = contentItem.eissn;
  864.           this.writeContentImage(contentItem, issnOrIsbn, false);
  865.         }
  866.       }
  867.     });
  868.   }
  869.  
  870.   writeContentImage(contentItem, issnOrIsbn, isIssn) {
  871.     // console.log("write content image");
  872.     // let dirs = RNFetchBlob.fs.dirs;
  873.     var path = RNFetchBlob.fs.dirs.DocumentDir + "/" + contentItem.id + ".jpg";
  874.     var url = config.coverUrl + contentItem.type.toLowerCase() + "/" + issnOrIsbn + ".jpg";
  875.     // console.log(url);
  876.     RNFetchBlob
  877.       .config({
  878.         fileCache: true,
  879.         // by adding this option, the temp files will have a file extension
  880.         path: path
  881.       })
  882.       .fetch('GET', url, {
  883.         //some headers ..
  884.       })
  885.       .then((res) => {
  886.         // the temp file path with file extension `png`
  887.         // console.log(res);
  888.         // console.log('The file saved to ', res.path());
  889.  
  890.         if (res["respInfo"] && res["respInfo"]["headers"]) {
  891.           var types = colProvider.findValueOfProperty(res["respInfo"]["headers"], "content-type");
  892.           if (types.length != 0) {
  893.             var ctype = types[0];
  894.             if (ctype.indexOf("xml") == -1 && ctype.indexOf("html") == -1) {
  895.               var aPath = "file://" + res.path();
  896.               for (var i = 0; i < contentList.length; i++) {
  897.                 if (contentList[i].id == contentItem.id) {
  898.                   contentList[i].image = "file://" + aPath;
  899.                   break;
  900.                 }
  901.               }
  902.               this.setState({ refresh: !this.state.refresh });
  903.             }
  904.           }
  905.         }
  906.       })
  907.   }
  908.  
  909.   createContentTitleList(data) {
  910.     var tempList = []
  911.     for (var i = 0; i < data.length; i++) {
  912.       tempList.push({
  913.         id: data[i].id,
  914.         title: data[i].title,
  915.         type: data[i].type,
  916.         iconName: (data[i].type.toUpperCase() == staticConfig.customLink || data[i].type.toUpperCase() == staticConfig.customInstituteContent || data[i].type.toUpperCase() == staticConfig.filtered) ? "icon_user_folder" : "icon_" + data[i].type.toLowerCase(),
  917.         active: false,
  918.         isExpanded: false,
  919.         containsContent: data[i].containsContent,
  920.         childMenuItems: data[i].childMenuItems ? this.createContentTitleList(JSON.parse(data[i].childMenuItems), data[i].type) : null
  921.       });
  922.     }
  923.     return tempList;
  924.   }
  925.  
  926.   maintainTypeListState = (typeList) => {
  927.     for (var m = 0; m < typeList.length; m++) {
  928.       if (typeList[m].active) {
  929.         if (typeList[m].childMenuItems?.length > 0) {
  930.           let res = this.maintainTypeListState(typeList[m].childMenuItems)
  931.           if (res != null) {
  932.             return res
  933.           }
  934.           else {
  935.             return typeList[m]
  936.           }
  937.         }
  938.         else {
  939.           return typeList[m]
  940.         }
  941.       }
  942.     }
  943.     return null
  944.   }
  945.  
  946.   // inserting the bibilolist data in typeList
  947.   async insertIntoTypeList(data, localRandomId, shouldFetchContentList) {
  948.     if (localRandomId == currentRandomTypeId) {
  949.       const { params } = this.props.route;
  950.       var activeItem = await this.maintainTypeListState(typeList)
  951.       typeList = [];
  952.       typeList = this.createContentTitleList(data);
  953.       // icon_user_folder
  954.       this.getBiblioContentList().then((data) => {
  955.         for (var i = 0; i < data.length; i++) {
  956.           if (data[i].type == staticConfig.favorite) {
  957.             typeList.push({
  958.               id: "fav_item",
  959.               title: data[i].title,
  960.               type: data[i].type,
  961.               iconName: "icon_" + data[i].type.toLowerCase(),
  962.               active: false,
  963.               containsContent: true,
  964.             });
  965.             console.log("getBiblioContentList::::", params, params?.contentType);
  966.             // if there is fav content item present and there is not any active item, then make fav section as active and show content
  967.             if (data[i].count != 0 && activeItem == null && !params?.contentType) {
  968.               typeList[typeList.length - 1].active = true;
  969.               currentType = typeList[typeList.length - 1].type;
  970.               currentTitle = typeList[typeList.length - 1].title;
  971.               menuItemId = typeList[typeList.length - 1].id
  972.               activeItem = typeList[typeList.length - 1];
  973.               console.log("first::::", params);
  974.             }
  975.             else if (params?.contentType) {  //deeplink use case when user have fav and without fav item set to active tab item
  976.               currentType = params?.contentType;
  977.               currentTitle = params?.cTitle;
  978.               menuItemId = params?.menuItemId;
  979.               activeItem = {
  980.                 id: params?.menuItemId,
  981.                 title: params?.cTitle,
  982.               };
  983.               console.log("second::::", params);
  984.             }
  985.             favIndex = typeList.length - 1;
  986.             break;
  987.           }
  988.         }
  989.         //if typelist length is less than 2 then there won't be 2nd index in type list array
  990.         if (currentType == "" || currentTitle == "" || currentType == null) {
  991.           for (var m = 0; m < typeList.length; m++) {
  992.             typeList[m].active = false;
  993.           }
  994.           if (typeList[0].containsContent)
  995.             typeList[0].active = true;
  996.           typeList[0].isExpanded = true;
  997.           currentType = typeList[0].type;
  998.           currentTitle = typeList[0].title;
  999.           menuItemId = typeList[0].id
  1000.         }
  1001.         else {
  1002.           this.updateTempList(typeList, activeItem, true)
  1003.           currentTitle = activeItem == null ? typeList[0].title : activeItem.title;
  1004.           menuItemId = activeItem == null ? typeList[0].id : activeItem.id
  1005.         }
  1006.         var tempFilters = this.state.pubFilters;
  1007.         console.log("shouldFetchContentList:::::", shouldFetchContentList)
  1008.         if (shouldFetchContentList) {
  1009.           this.callbackFun(tempFilters, true);
  1010.           this.clearParams();
  1011.           // if (!params?.contentType) {
  1012.           //   this.callbackFun(tempFilters, true);
  1013.           //   // this.clearParams();
  1014.           //   console.log("if:::::")
  1015.           // } else {
  1016.           //   this.callbackFun(tempFilters);
  1017.           //   console.log("else:::::")
  1018.           // }
  1019.         }
  1020.       });
  1021.     }
  1022.   }
  1023.  
  1024.   //get biblio content list
  1025.   getBiblioContentList() {
  1026.     return new Promise((resolve, reject) => {
  1027.       var shouldFetchContentList = true;
  1028.       conProvider.getBiblioSql().then((data) => {
  1029.         if (data.length > 0) {
  1030.           shouldFetchContentList = false;
  1031.           resolve(data);
  1032.         }
  1033.  
  1034.         conProvider.getBiblioListGraph().then((resJson) => {
  1035.           //updating the typeList
  1036.           if (resJson.length > 0) {
  1037.             resolve(resJson);
  1038.           } else {
  1039.             if (shouldFetchContentList)
  1040.               reject();
  1041.           }
  1042.         }).catch((error) => {
  1043.           if (shouldFetchContentList)
  1044.             reject(error);
  1045.         });
  1046.  
  1047.       }).catch(() => {
  1048.         reject();
  1049.       });
  1050.     });
  1051.   }
  1052.  
  1053.  
  1054.   //get biblio content list
  1055.   getMenuItemsList() {
  1056.     currentRandomTypeId = apiProvider.generateUUID();
  1057.     var localRandomId = currentRandomTypeId;
  1058.     return new Promise((resolve, reject) => {
  1059.       var shouldFetchContentList = true;
  1060.       conProvider.getMenuItemSql().then((data) => {
  1061.         if (data.length > 0) {
  1062.           this.insertIntoTypeList(data, localRandomId, true);
  1063.           shouldFetchContentList = false;
  1064.           resolve(data);
  1065.         }
  1066.         conProvider.getMenuItemsGraph().then((resJson) => {
  1067.           //updating the typeList
  1068.           if (resJson.length > 0) {
  1069.             this.insertIntoTypeList(resJson, localRandomId, shouldFetchContentList);
  1070.             resolve(resJson);
  1071.           } else {
  1072.             if (shouldFetchContentList)
  1073.               reject();
  1074.           }
  1075.         }).catch((error) => {
  1076.           if (shouldFetchContentList)
  1077.             reject(error);
  1078.         });
  1079.  
  1080.       }).catch(() => {
  1081.         reject();
  1082.       });
  1083.     });
  1084.   }
  1085.  
  1086.   //root error message on full screen
  1087.   showError(msg, imagePath) {
  1088.     this.drawer.closeDrawer();
  1089.     graphError = ""
  1090.     this.setState({
  1091.       accessDenied: true,
  1092.       deniedMessage: msg,
  1093.       contentLoading: false,
  1094.       contentLength: 0,
  1095.       errorModal: true,
  1096.       drawerLockMode: "locked-closed",
  1097.       isButton: false,
  1098.       imagePath: imagePath,
  1099.       errorLoading: false
  1100.     });
  1101.     varProvider.drawerLockMode = "locked-closed";
  1102.   }
  1103.  
  1104.   openMenu() {
  1105.     this.drawer.openDrawer();
  1106.   }
  1107.  
  1108.   changeView() {
  1109.     this.setState({ isCardView: !this.state.isCardView });
  1110.   }
  1111.  
  1112.   callbackFun(activeFilters, isBgContent) {
  1113.     var isFilter = false;
  1114.     var appliedFilter = [];
  1115.     var topKey, bottomKey, dataKey, dataValue;
  1116.     for (var i = 0; i < activeFilters.length; i++) {
  1117.       if (activeFilters[i].active) {
  1118.         isFilter = true;
  1119.         // if (i == 0) {
  1120.         topKey = "$searchText: String";
  1121.         bottomKey = "libTitle_contains: $searchText";
  1122.         dataKey = "searchText";
  1123.         dataValue = activeFilters[0].value;
  1124.         // }
  1125.  
  1126.         appliedFilter.push({
  1127.           "topKey": topKey,
  1128.           "bottomKey": bottomKey,
  1129.           "dataKey": dataKey,
  1130.           "dataValue": dataValue,
  1131.         });
  1132.       }
  1133.     }
  1134.  
  1135.     if (appliedFilter.length == 0) {
  1136.       this.setState({
  1137.         "isFilter": false,
  1138.         appliedFilter: appliedFilter
  1139.       });
  1140.     } else {
  1141.       this.setState({
  1142.         "isFilter": true,
  1143.         appliedFilter: appliedFilter
  1144.       });
  1145.     }
  1146.  
  1147.     var tempJson = {
  1148.       "isFilter": isFilter,
  1149.       "appliedFilter": appliedFilter,
  1150.       "skip": 0,
  1151.       "menuItemId": menuItemId
  1152.     }
  1153.  
  1154.     this.initContentList(tempJson, activeFilters, isBgContent);
  1155.   }
  1156.  
  1157.   initContentList(tempJson, activeFilters, isBgContent) {
  1158.     //console.log("initContentList::::", isBgContent);
  1159.     if (!isBgContent) {
  1160.       //console.log("isBgContent", isBgContent, contentList?.length);
  1161.       contentList = [];
  1162.       graphError = ""
  1163.       this.setState({
  1164.         contentLoading: true,
  1165.         contentLength: 0,
  1166.         pubFilters: activeFilters,
  1167.         accessDenied: false,
  1168.         errorModal: false,
  1169.         drawerLockMode: "unlocked",
  1170.         refreshTypes: !this.state.refreshTypes,
  1171.         errorLoading: false
  1172.       });
  1173.       varProvider.drawerLockMode = "unlocked";
  1174.       noMoreData = false;
  1175.     } else {
  1176.       //console.log("isBgContent else", isBgContent, contentList.length);
  1177.       noMoreData = false;
  1178.       //fetch content list from sqlite and compare it with new list fetched via graph query
  1179.       //if there isn't any change than no need to reset content list
  1180.       if (contentList.length != 0 && connection.isConnectedFun()) {
  1181.         //console.log("noMoreData");
  1182.         //return function here so that next lines does not execute
  1183.         tempJson["type"] = currentType;
  1184.         tempJson["shouldDelete"] = "check";
  1185.         tempJson["first"] = contentList.length;
  1186.         return this.loadContentList(tempJson);
  1187.       }
  1188.     }
  1189.     tempJson["type"] = currentType;
  1190.     tempJson["shouldDelete"] = "true";
  1191.     tempJson["first"] = pagingCount;
  1192.     if (connection.isConnectedFun()) {
  1193.       //console.log("connection.isConnectedFun");
  1194.       this.loadContentList(tempJson);
  1195.     }
  1196.   }
  1197.  
  1198.   callbackFavorite(isFavorite) {
  1199.     if (currentType == staticConfig.favorite && !isFavorite) {
  1200.       this.removeItem(cloneIt);
  1201.     } else {
  1202.       cloneIt.isFavorite = isFavorite;
  1203.       this.setState({ refresh: !this.state.refresh });
  1204.     }
  1205.   }
  1206.  
  1207.   openFilters() {
  1208.     const { navigate } = this.props.navigation;
  1209.     navigate('ConFilters', { "callbackFun": this.callbackFun, "pubFilters": this.state.pubFilters, "contentType": currentType });
  1210.   }
  1211.  
  1212.   openContent(item) {
  1213.     // console.log(item);
  1214.     cloneIt = item;
  1215.     const { navigate } = this.props.navigation;
  1216.     if (item.type == staticConfig.journal) {
  1217.       if (this.state.isVPNConfigAccepted || this.state.isVPNOptional) {
  1218.         if ((item.issn || item.eissn) && shouldShowJournalDetail == "true") {
  1219.           navigate('JournalArticles', { "journalItem": item, "callbackFavorite": this.callbackFavorite, "refScreen": varProvider.currentScreen });
  1220.         } else {
  1221.           if (connection.isConnectedFun()) {
  1222.             var pubApiUrl = item.url;
  1223.             if (pubApiUrl.includes(config.pubApiShort)) {
  1224.               pubApiUrl = pubApiUrl.replace(/:token/g, varProvider.lastToken);
  1225.             }
  1226.             navigate('BrowserView', { "url": pubApiUrl, "refScreen": varProvider.currentScreen });
  1227.             this.logContentOpenEvent(item.type, item.id)
  1228.           } else {
  1229.             Toast.showShortCenter(translate("PLEASE_CONNECT"));
  1230.           }
  1231.         }
  1232.       } else {
  1233.         addVPNPopup = true;
  1234.         this.setState({
  1235.           permissionModal: true
  1236.         });
  1237.       }
  1238.     }
  1239.     else {
  1240.       if (connection.isConnectedFun()) {
  1241.         if (this.state.isVPNConfigAccepted || this.state.isVPNOptional) {
  1242.           if (item.url) {
  1243.             // checking if multiUrl is present for database only
  1244.             if (item.multiUrls !== null && item.multiUrls.length > 0 && item.type === staticConfig.database) {
  1245.               if (item.multiUrls.length === 1) {
  1246.                 this.openContentUrl(item.multiUrls[0].url, false, item.type, item.id) // false represent that there are no multi urls OR only one multi url
  1247.               }
  1248.               else {
  1249.                 multiUrlsList = []
  1250.                 item.multiUrls.map((multiUrlsitem) => {
  1251.                   multiUrlsList.push({ title: multiUrlsitem.resourceGroup.name, onPressFun: this.openContentUrl.bind(this, multiUrlsitem.url, true, item.type, item.id) }) // true represent that there are more then one multiUrl
  1252.                 })
  1253.                 this.setState({ multiUrlsView: true })
  1254.               }
  1255.             }
  1256.             else {
  1257.               this.openContentUrl(item.url, false, item.type, item.id) // false represent that there are no multi urls OR only one multi url
  1258.             }
  1259.           }
  1260.         } else {
  1261.           addVPNPopup = true;
  1262.           this.setState({
  1263.             permissionModal: true
  1264.           });
  1265.         }
  1266.       } else {
  1267.         Toast.showShortCenter(translate("PLEASE_CONNECT"));
  1268.       }
  1269.     }
  1270.   }
  1271.  
  1272.   openContentUrl = (url, isMultiUrl, type, id) => {
  1273.     const { navigate } = this.props.navigation;
  1274.     if (isMultiUrl) {
  1275.       this.setState({ multiUrlsView: false })
  1276.       multiUrlsList = []
  1277.     }
  1278.     var pubApiUrl = url
  1279.     if (pubApiUrl.includes(config.pubApiShort)) {
  1280.       pubApiUrl = pubApiUrl.replace(/:token/g, varProvider.lastToken);
  1281.     }
  1282.     navigate('BrowserView', { "url": pubApiUrl, "refScreen": varProvider.currentScreen });
  1283.     this.logContentOpenEvent(type, id)
  1284.   }
  1285.  
  1286.   logContentOpenEvent(type, eResourceId) {
  1287.     let contentOpenJson = {
  1288.       "type": type,
  1289.       "eResourceId": eResourceId
  1290.     }
  1291.     analyticsProvider.logAnalyticsJson("eResourceOpen", contentOpenJson);
  1292.   }
  1293.  
  1294.   logPdfScreenViewEvent(isNavigatingBack) {
  1295.     let screenViewJson = {
  1296.       "name": isNavigatingBack ? currentType : screenNames.PDFView,
  1297.       "previous": isNavigatingBack ? screenNames.PDFView : currentType
  1298.     };
  1299.     analyticsProvider.logAnalyticsJson("ScreenView", screenViewJson);
  1300.   }
  1301.  
  1302.   iosPdfEvent(pdfObject) {
  1303.  
  1304.     const viewerDismissedSubscription = pdfObject.addListener(
  1305.       'ViewerWillDismiss',
  1306.       (highlightObject) => {
  1307.         // console.log("ViewerWillDismiss Collection screen");
  1308.         // console.log(highlightObject);
  1309.         viewerDismissedSubscription.remove();
  1310.         this.logPdfScreenViewEvent(true);
  1311.         varProvider.currentScreen = screenNames.Content;
  1312.       }
  1313.     );
  1314.   }
  1315.  
  1316.   removeFilter(item) {
  1317.     var tempFilters = this.state.pubFilters;
  1318.     for (var i = 0; i < tempFilters.length; i++) {
  1319.       if (item.value == tempFilters[i].value) {
  1320.         tempFilters[i].active = false;
  1321.         break;
  1322.       }
  1323.     }
  1324.  
  1325.     this.callbackFun(tempFilters);
  1326.   }
  1327.  
  1328.   viewDetails(item) {
  1329.     const { navigate } = this.props.navigation;
  1330.     navigate('ContentDescription', { "item": item, "openContent": this.openContent });
  1331.   }
  1332.  
  1333.   favoriteContent(item) {
  1334.     if (connection.isConnectedFun()) {
  1335.       var action;
  1336.       if (item.isFavorite) {
  1337.         item.isFavorite = false;
  1338.         action = "UNFAVORITE";
  1339.       }
  1340.       else {
  1341.         item.isFavorite = true;
  1342.         action = "FAVORITE";
  1343.       }
  1344.  
  1345.       var secondArg = false;
  1346.  
  1347.       var tempJson = {};
  1348.       var contentIds = [];
  1349.       var id = item.contentType == staticConfig.customInstituteContent ? item.customInsContentId : item.id
  1350.       contentIds.push(id);
  1351.       tempJson["contentIds"] = contentIds;
  1352.       tempJson["action"] = action;
  1353.       tempJson["isFavorite"] = item.isFavorite;
  1354.       tempJson["type"] = item.type;
  1355.       if (currentType == staticConfig.favorite && !item.isFavorite) {
  1356.         this.removeItem(item);
  1357.       }
  1358.       conProvider.favoriteContentGraph(tempJson, secondArg).then((data) => {
  1359.         if (item.type == staticConfig.journal && item.isFavorite) {
  1360.           jaProvider.cacheJournalArticles();
  1361.         }
  1362.       }).catch((error) => {
  1363.       });
  1364.       this.setState({ refresh: !this.state.refresh });
  1365.     }
  1366.     else {
  1367.       Toast.showShortCenter(translate("PLEASE_CONNECT"));
  1368.     }
  1369.   }
  1370.  
  1371.   removeItem(item) {
  1372.     for (var i = 0; i < contentList.length; i++) {
  1373.       if (contentList[i].id == item.id) {
  1374.         contentList.splice(i, 1);
  1375.         break;
  1376.       }
  1377.     }
  1378.     this.setState({ refresh: !this.state.refresh });
  1379.   }
  1380.  
  1381.   FlatListItemSeparator = () => {
  1382.     return (
  1383.       <View
  1384.         style={styles.contentBottomBorder}
  1385.       />
  1386.     );
  1387.   }
  1388.  
  1389.   // to handle scroll pagination to load more content
  1390.   handleLoadMore = () => {
  1391.     if (contentList.length > pagingCount - 1) {
  1392.       if (!noMoreData) {
  1393.         if (!isInfiniteOn) {
  1394.           this.setState({ footerLoading: true });
  1395.           isInfiniteOn = true;
  1396.           var skipCount = contentList.length;
  1397.  
  1398.           var tempJson = {
  1399.             "isFilter": this.state.isFilter,
  1400.             "appliedFilter": this.state.appliedFilter,
  1401.             "skip": skipCount,
  1402.             "first": pagingCount,
  1403.             "type": currentType,
  1404.             "shouldDelete": "false",
  1405.             "menuItemId": menuItemId
  1406.           }
  1407.           console.log("handleLoadMore", tempJson);
  1408.           this.loadContentList(tempJson);
  1409.         }
  1410.       }
  1411.     } else {
  1412.       if (isListFromGraph)
  1413.         noMoreData = true;
  1414.     }
  1415.   };
  1416.  
  1417.   closeGuide = () => {
  1418.     this.setState({ showGuide: false })
  1419.     setProvider.closeGuide("iseResourcesGuideShown");
  1420.   }
  1421.  
  1422.   hideModalCallback = () => {
  1423.     this.checkIfVPNCreated()
  1424.   }
  1425.  
  1426.   callbackVpnInfo() {
  1427.     this.setState({
  1428.       permissionModal: true
  1429.     });
  1430.   }
  1431.  
  1432.   openVpnInfo() {
  1433.     this.setState({
  1434.       permissionModal: false
  1435.     });
  1436.     const { navigate } = this.props.navigation;
  1437.     navigate('VpnInfo', { "isModal": true, "shouldShowDNSSetting": false, "callbackVpnInfo": this.callbackVpnInfo, "refScreen": screenNames.Content });
  1438.   }
  1439.  
  1440.   renderFooter = () => {
  1441.     if (!this.state.footerLoading) return null;
  1442.  
  1443.     return (
  1444.       <View style={styles.loaderIndicator}>
  1445.         <Spinner style={styles.spinner} size={22} type="Circle" color="#333" />
  1446.       </View>
  1447.     );
  1448.   };
  1449.  
  1450.   renderEmpty = () => {
  1451.     console.log("renderEmpty:::", currentType, currentTitle, contentList?.length);
  1452.     var imagePath, isButton, buttonText, buttonFunction, title, text = ""
  1453.     if (currentType == staticConfig.favorite) {
  1454.       imagePath = imageJson.fav_content_empty;
  1455.       title = this.state.isFilter ? translate("FAV_FILTER_EMPTY") : translate("FC_EMPTY");
  1456.       text = this.state.isFilter ? translate("FAV_FILTER_EMPTY_DATA") : translate("FC_EMPTY_DATA1");
  1457.       isButton = true
  1458.       buttonText = translate("VIEW_MORE")
  1459.       buttonFunction = this.openMenu;
  1460.       // we have to change this , so i have not included it in en.json
  1461.     } else if (currentType == staticConfig.database) {
  1462.       imagePath = imageJson.content_empty;
  1463.       title = this.state.isFilter ? translate("CONTENT_DATABASE_FILTER_EMPTY") : translate("CONTENT_DATABASE_EMPTY");
  1464.       text = this.state.isFilter ? translate("CONTENT_DATABASE_FILTER_EMPTY_DATA") : translate("CONTENT_DATABASE_EMPTY_DATA", { currentTitle: currentTitle });
  1465.     }
  1466.     else if (currentType == staticConfig.journal) {
  1467.       imagePath = imageJson.content_empty;
  1468.       title = this.state.isFilter ? translate("CONTENT_JOURNAL_FILTER_EMPTY") : translate("CONTENT_JOURNAL_EMPTY");
  1469.       text = this.state.isFilter ? translate("CONTENT_JOURNAL_FILTER_EMPTY_DATA") : translate("CONTENT_JOURNAL_EMPTY_DATA", { currentTitle: currentTitle });
  1470.     }
  1471.     else if (currentType == staticConfig.ebook) {
  1472.       imagePath = imageJson.content_empty;
  1473.       title = this.state.isFilter ? translate("CONTENT_EBOOK_FILTER_EMPTY") : translate("CONTENT_EBOOK_EMPTY");
  1474.       text = this.state.isFilter ? translate("CONTENT_EBOOK_FILTER_EMPTY_DATA") : translate("CONTENT_EBOOK_EMPTY_DATA", { currentTitle: currentTitle });
  1475.     }
  1476.     else if (currentType == staticConfig.customInstituteContent) {
  1477.       imagePath = imageJson.content_empty;
  1478.       title = this.state.isFilter ? translate("CONTENT_CUSTOMINSCON_FILTER_EMPTY") : translate("CONTENT_CUSTOMINSCON_EMPTY")
  1479.       text = this.state.isFilter ? translate("CONTENT_CUSTOMINSCON_FILTER_EMPTY_DATA") : translate("CONTENT_CUSTOMINSCON_EMPTY_DATA", { currentTitle: currentTitle })
  1480.     }
  1481.     else if (currentType == staticConfig.customLink) {
  1482.       imagePath = imageJson.content_empty;
  1483.       title = this.state.isFilter ? translate("CONTENT_CUSTOMLINK_FILTER_EMPTY") : translate("CONTENT_CUSTOMLINK_EMPTY")
  1484.       text = this.state.isFilter ? translate("CONTENT_CUSTOMLINK_FILTER_EMPTY_DATA") : translate("CONTENT_CUSTOMLINK_EMPTY_DATA", { currentTitle: currentTitle })
  1485.     }
  1486.     else if (currentType == staticConfig.filtered) {
  1487.       imagePath = imageJson.content_empty;
  1488.       title = this.state.isFilter ? translate("CONTENT_FILTERED_FILTER_EMPTY") : translate("CONTENT_FILTERED_EMPTY")
  1489.       text = this.state.isFilter ? translate("CONTENT_FILTERED_FILTER_EMPTY_DATA") : translate("CONTENT_FILTERED_EMPTY_DATA", { currentTitle: currentTitle })
  1490.     }
  1491.  
  1492.     return (
  1493.       <View>
  1494.         {this.state.errorLoading ?
  1495.           <View>
  1496.             <EmptyScreen
  1497.               imagePath={graphError && graphError.success == undefined ? imageJson.httpError_img : imageJson.something_wrong_here}
  1498.               Title={graphError ? graphError.shortDesc : translate("TECHNICAL_EMPTY")}
  1499.               Text={graphError ? graphError.desc : translate("TECHNICAL_EMPTY_DATA1")}
  1500.               isButton={true}
  1501.               buttonText={translate("SU_EMPTY")}
  1502.               buttonCallback={this.buttonCallback}
  1503.             />
  1504.           </View>
  1505.           :
  1506.           this.state.isFilter ?
  1507.             <View>
  1508.               <EmptyScreen
  1509.                 imagePath={imageJson.no_search_result}
  1510.                 Title={title}
  1511.                 Text={text}
  1512.               />
  1513.             </View>
  1514.             :
  1515.             <View>
  1516.               <EmptyScreen
  1517.                 imagePath={imagePath}
  1518.                 Title={title}
  1519.                 Text={text}
  1520.                 isButton={isButton}
  1521.                 buttonText={buttonText}
  1522.                 buttonCallback={buttonFunction}
  1523.               />
  1524.             </View>
  1525.         }
  1526.       </View>
  1527.     );
  1528.   }
  1529.  
  1530.   renderEmptyDrawer = () => {
  1531.  
  1532.     return (
  1533.       <View>
  1534.         {this.state.errorLoading ?
  1535.           <View>
  1536.             <Text style={{ textAlign: 'center', color: '#000' }}>{translate("BIBLIO_FAILED")}</Text>
  1537.           </View>
  1538.           :
  1539.           <View style={styles.loaderIndicator}>
  1540.             <Spinner style={styles.spinner} size={22} type="Circle" color="#333" />
  1541.           </View>
  1542.         }
  1543.       </View>
  1544.     );
  1545.   }
  1546.  
  1547.   downloadFromLink = (item, retry) => {
  1548.     const { navigate } = this.props.navigation;
  1549.     this.setState({ isLinkLoading: true });
  1550.     conProvider.getDownloadURlFromS3(item).then((url) => {
  1551.       this.setState({ isLinkLoading: false });
  1552.       navigate('BrowserView', { "url": url, "refScreen": varProvider.currentScreen });
  1553.       this.logContentOpenEvent(item.type, item.id)
  1554.     }).catch((error) => {
  1555.       if (retry) {
  1556.         this.downloadFromLink(item, false)
  1557.       }
  1558.       else {
  1559.         this.setState({ isLinkLoading: false });
  1560.         setTimeout(() => {
  1561.           Toast.showShortCenter(translate("ERROR_UNKNOWN_DESC"));
  1562.         }, 400)
  1563.       }
  1564.     });
  1565.   }
  1566.  
  1567.   checkS3Url = (item) => {
  1568.     if (this.state.isVPNConfigAccepted || this.state.isVPNOptional) {
  1569.       if (item.url.includes("s3://")) {
  1570.         this.downloadFromLink(item, true)
  1571.       } else {
  1572.         this.openContent(item)
  1573.       }
  1574.     }
  1575.     else {
  1576.       addVPNPopup = true;
  1577.       this.setState({
  1578.         permissionModal: true
  1579.       });
  1580.     }
  1581.   }
  1582.  
  1583.   _renderContentCard = ({ item }) => (
  1584.     <ContentListView
  1585.       key={item.id}
  1586.       title={item.title}
  1587.       libDescription={item.libDescription}
  1588.       type={item.type}
  1589.       publisherName={item.publisherName}
  1590.       phImage={item.phImage}
  1591.       image={item.image}
  1592.       isFetched={item.isFetched}
  1593.       smallImage={item.smallImage}
  1594.       isFavorite={item.isFavorite}
  1595.       currentType={currentType}
  1596.       isVPNConfigAccepted={this.state.isVPNConfigAccepted || this.state.isVPNOptional}
  1597.       data={item}
  1598.       openContent={item.type == "LINK" ? this.checkS3Url : this.openContent}
  1599.       favoriteContent={this.favoriteContent}
  1600.       successFetchingImage={this.successFetchingImage}
  1601.       errorFetchingImage={this.errorFetchingImage}
  1602.       viewDetails={this.viewDetails}
  1603.     />
  1604.   )
  1605.  
  1606.   hideActionSheetModal = () => {
  1607.     multiUrlsList = []
  1608.     this.setState({ multiUrlsView: false });
  1609.   }
  1610.  
  1611.   closeActionSheetModal = () => {
  1612.     multiUrlsList = []
  1613.     this.setState({ multiUrlsView: false });
  1614.   }
  1615.  
  1616.   render() {
  1617.     var renderFavFooter = (typeList && typeList.length > 0)
  1618.       ?
  1619.       <TouchableOpacity
  1620.         activeOpacity={0.7}
  1621.         style={drawerStyles.favMenuItem}
  1622.         onPress={() => this.menuItemPress(typeList[favIndex], true)}
  1623.       >
  1624.         <View style={drawerStyles.menuLeftIconView}>
  1625.           <CustomIcons style={[drawerStyles.menuLeftIcon, typeList[favIndex]?.active && drawerStyles.menuLeftIconActive]} name="icon_fav_content" />
  1626.         </View>
  1627.         <Text style={[drawerStyles.menuItemText, typeList[favIndex]?.active && drawerStyles.menuItemTextDefault]}>{typeList[favIndex]?.title}</Text>
  1628.         <View style={drawerStyles.menuItemRightView}>
  1629.         </View>
  1630.       </TouchableOpacity>
  1631.       :
  1632.       null;
  1633.  
  1634.     var menu = <SafeAreaView
  1635.       edges={['right', 'top', 'left']}
  1636.       style={drawerStyles.mainContainer}>
  1637.       <View style={drawerStyles.headerContainer}>
  1638.         <View style={drawerStyles.headerTop}>
  1639.           <Text style={drawerStyles.headerTopLeft}>{translate("ALL_CONTENT")}</Text>
  1640.         </View>
  1641.       </View>
  1642.       {
  1643.         this.state.noData ?
  1644.           <View>
  1645.           </View> :
  1646.           <View style={{ flex: 1 }}>
  1647.             <FlatList
  1648.               bounces={typeList.length == 0 ? false : true}
  1649.               data={typeList}
  1650.               extraData={this.state}
  1651.               keyExtractor={(item) => item.id}
  1652.               ListEmptyComponent={this.renderEmptyDrawer}
  1653.               renderItem={({ item, index }) =>
  1654.                 item.type !== staticConfig.favorite &&
  1655.                 <View key={item.id}>
  1656.                   <TouchableOpacity
  1657.                     activeOpacity={0.7}
  1658.                     style={drawerStyles.menuItem}
  1659.                     onPress={() => this.menuItemPress(item, true)}
  1660.                   >
  1661.                     <View style={drawerStyles.menuLeftIconView}>
  1662.                       <CustomIcons style={[drawerStyles.menuLeftIcon, item.active && drawerStyles.menuLeftIconActive, { opacity: this.state.isConnected ? 1 : 0.5 }]} name={item.iconName} />
  1663.                     </View>
  1664.                     <Text style={[drawerStyles.menuItemText, item.active && drawerStyles.menuItemTextDefault, { opacity: this.state.isConnected ? 1 : 0.5 }]}>
  1665.                       {item.title}
  1666.                     </Text>
  1667.                     {item.childMenuItems.length >= 1 &&
  1668.                       <CustomIcons style={item.active ? drawerStyles.arrowIconActive : drawerStyles.arrowIcon} name={item.isExpanded ? "icon_down_arrow_line" : "icon_next_arrow_line"} />
  1669.                     }
  1670.  
  1671.                   </TouchableOpacity>
  1672.                   {item.isExpanded && item.childMenuItems.length >= 1 && item.childMenuItems.map((item, key) =>
  1673.                     <View key={item.id}>
  1674.                       <TouchableOpacity
  1675.                         activeOpacity={0.7}
  1676.                         style={drawerStyles.menuItem}
  1677.                         onPress={() => this.menuItemPress(item, true)}
  1678.                       >
  1679.                         <Text style={[drawerStyles.childMenuItemText, item.active && drawerStyles.childMenuItemTextDefault, { opacity: this.state.isConnected ? 1 : 0.5 }]}>
  1680.                           {item.title}
  1681.                         </Text>
  1682.                       </TouchableOpacity>
  1683.                     </View>
  1684.                   )}
  1685.                 </View>
  1686.               }
  1687.  
  1688.             />
  1689.             {renderFavFooter}
  1690.           </View>
  1691.       }
  1692.     </SafeAreaView >
  1693.  
  1694.     var headerBar =
  1695.       <View style={[Platform.OS === 'ios' ? styles.newHeaderContainer : styles.newHeaderContainerAndroid, { elevation: (this.state.errorModal) ? 0 : 4 }]}>
  1696.         <View style={Platform.OS === 'ios' ? styles.newTopHeaderContainer : styles.newTopHeaderContainerAndroid}>
  1697.           <TouchableOpacity activeOpacity={0.7} style={styles.newMenuButtonContainer} onPress={() => this.openMenu()}>
  1698.             <CustomIcons style={styles.newMenuButtonIcon} name="icon_side_menu" />
  1699.             <View style={styles.newMenuButtonRedDot}><View style={styles.newMenuButtonRedDotChild}></View></View>
  1700.           </TouchableOpacity>
  1701.           <View style={styles.newHeaderLeftButtonView}>
  1702.             <Text style={styles.newHeaderLeftButtonText} numberOfLines={1}>{currentTitle}</Text>
  1703.           </View>
  1704.  
  1705.           <TouchableOpacity activeOpacity={0.5} disabled={contentList.length == 0 && !this.state.isFilter} style={styles.newHeaderRightButtonView} onPress={() => this.openFilters()}>
  1706.             <CustomIcons style={[styles.newHeaderRightButtonIcon, contentList.length == 0 && !this.state.isFilter && { color: EStyleSheet.value("$disableIcon") }]} name="icon_filter" />
  1707.           </TouchableOpacity>
  1708.  
  1709.         </View>
  1710.       </View>
  1711.  
  1712.     return (
  1713.       <DrawerLayout
  1714.         drawerWidth={300}
  1715.         // useNativeAnimations={true}
  1716.         drawerBackgroundColor="white"
  1717.         ref={(_drawer) => { this.drawer = _drawer; varProvider.conDrawer = _drawer; }}
  1718.         onDrawerClose={() => { this.onDrawerClose() }}
  1719.         drawerPosition={DrawerLayout.positions.Left}
  1720.         drawerLockMode={this.state.drawerLockMode}
  1721.         renderNavigationView={() => menu}>
  1722.         <SafeAreaView
  1723.           edges={['right', 'top', 'left']}
  1724.           style={{ backgroundColor: "#fff", flex: 1 }}>
  1725.  
  1726.           <GuideView slides={guideImageJson.eResources} screen={"eResources"} showGuide={this.state.showGuide} closeGuide={this.closeGuide} hideCallback={this.hideModalCallback} />
  1727.  
  1728.           {/* to hide the header bar when there is any error modal on page*/}
  1729.           {!this.state.errorModal && headerBar}
  1730.  
  1731.           <View style={styles.mainContainer}>
  1732.  
  1733.             <View>
  1734.               <ScrollView style={styles.chipScrollView} horizontal={true}>
  1735.                 {this.state.pubFilters.map((item, key) =>
  1736.                 (
  1737.                   <View key={key}>
  1738.                     {item.active &&
  1739.                       <View>
  1740.                         <Chip
  1741.                           rootStyle={styles.chipContainer}
  1742.                           chipTitle={item.chipTitle}
  1743.                           removeCallback={() => this.removeFilter(item)}
  1744.                         />
  1745.                       </View>
  1746.                     }
  1747.                   </View>
  1748.                 ))
  1749.                 }
  1750.               </ScrollView>
  1751.             </View>
  1752.  
  1753.             {
  1754.               this.state.contentLoading ?
  1755.                 <ArticleLoader />
  1756.                 :
  1757.                 <View style={{ flex: 1 }}>
  1758.  
  1759.                   {this.state.accessDenied ?
  1760.                     <View style={{ margin: 16 }}>
  1761.                       <Text style={{ color: "black", fontSize: 16 }}>{this.state.deniedMessage}</Text>
  1762.                     </View>
  1763.                     :
  1764.                     <FlatList
  1765.                       bounces={contentList.length == 0 ? false : true}
  1766.                       style={{ marginBottom: 0 }}
  1767.                       contentContainerStyle={[{ paddingTop: 12, paddingBottom: 8 }, contentList.length == 0 && { justifyContent: 'center', height: "100%" }]}
  1768.                       data={contentList}
  1769.                       extraData={this.state.refresh}
  1770.                       ListFooterComponent={this.renderFooter}
  1771.                       ListEmptyComponent={this.renderEmpty}
  1772.                       onEndReached={this.handleLoadMore}
  1773.                       onEndReachedThreshold={0.5}
  1774.                       renderItem={this._renderContentCard}
  1775.                     />
  1776.                   }
  1777.                 </View>
  1778.             }
  1779.  
  1780.           </View>
  1781.  
  1782.           {this.state.errorModal &&
  1783.             <View style={[styles.errorModalView, Platform.OS == "ios" && { zIndex: 3 }]}>
  1784.               <View style={styles.errorModalBackView}>
  1785.                 <View style={styles.errorModalFrontView}>
  1786.                   <View style={styles.logoContainer}>
  1787.                     {this.state.imagePath &&
  1788.                       <Image style={styles.logo} source={this.state.imagePath} resizeMode="contain" />
  1789.                     }
  1790.                     <Text style={styles.errorTitle}>{this.state.deniedMessage}</Text>
  1791.                     {this.state.isButton &&
  1792.                       <View>
  1793.                         <Text style={[styles.errorText, { fontWeight: 'bold', textAlign: 'center' }]}>{this.state.bottomText}</Text>
  1794.                         <TouchableOpacity activeOpacity={0.8} style={[styles.errorButton, { width: "60%" }]} onPress={this.gotoCollection}>
  1795.                           <Text style={styles.errorButtonText}>{translate("READ_OFFLINE")}</Text>
  1796.                         </TouchableOpacity>
  1797.                       </View>
  1798.                     }
  1799.                   </View>
  1800.                 </View>
  1801.               </View>
  1802.             </View>
  1803.           }
  1804.  
  1805.           <ActionSheet
  1806.             isVisible={this.state.multiUrlsView}
  1807.             closeCallback={this.closeActionSheetModal}
  1808.             hideCallback={this.hideActionSheetModal}
  1809.             modalWidth={modalWidth}
  1810.             modalHeight={modalHeight}
  1811.             backdropColor="#333"
  1812.             backdropOpacity={0.3}
  1813.             isMultiUrlView={this.state.multiUrlsView}
  1814.             data={multiUrlsList}
  1815.           />
  1816.  
  1817.           <Modal
  1818.             animationIn="zoomIn"
  1819.             animationOut="zoomOut"
  1820.             isVisible={this.state.permissionModal}
  1821.             supportedOrientations={['portrait', 'landscape']}
  1822.             useNativeDriver={true}
  1823.             hideModalContentWhileAnimating={true}
  1824.             style={styles.mainContent}
  1825.           >
  1826.             <View style={styles.permissionModal}>
  1827.               <ScrollView contentContainerStyle={styles.vpnPopupContainer} alwaysBounceVertical={false}>
  1828.                 <View style={styles.logoContainer}>
  1829.                   <Image style={styles.vpnPermissionImage} source={imageJson.vpn_permission} resizeMode="contain" />
  1830.                   <Text style={styles.errorTitle}>{addVPNPopup ? translate("VPN_NOT_CONFIGURED") : translate("VPN_PERMISSION")}</Text>
  1831.                   <View style={styles.errorVPNDataView}>
  1832.                     <Text style={styles.errorTextContainer}>
  1833.                       <Text style={styles.errorText}>{addVPNPopup ? translate("VPN_NOT_CONFIGURED_DATA") : translate("VPN_PERMISSION_DATA")}</Text>
  1834.                       <Text style={styles.vpnLearnMoreButtonText} onPress={() => { this.openVpnInfo() }}> {translate("VPN_LEARN_MORE")}</Text>
  1835.                     </Text>
  1836.  
  1837.                     <TouchableOpacity activeOpacity={0.8} style={[styles.errorButton, { marginBottom: 30 }]} onPress={() => { this.proceedWithVPNPermission() }}>
  1838.                       <Text style={styles.errorButtonText}>{addVPNPopup ? translate("VPN_NOT_CONFIGURED_BUTTON") : translate("VPN_PERMISSION_BUTTON")}</Text>
  1839.                     </TouchableOpacity>
  1840.  
  1841.                   </View>
  1842.                 </View>
  1843.               </ScrollView>
  1844.             </View>
  1845.           </Modal>
  1846.           <Modal
  1847.             animationIn="zoomInUp"
  1848.             animationOut="zoomOut"
  1849.             backdropColor="#333"
  1850.             backdropOpacity={0.3}
  1851.             useNativeDriver={true}
  1852.             hideModalContentWhileAnimating={true}
  1853.             supportedOrientations={['portrait', 'landscape']}
  1854.             isVisible={this.state.isLinkLoading}
  1855.           >
  1856.             <View style={styles.switchLoadingView}>
  1857.               <ActivityIndicator size='large' color={Platform.OS === 'android' ? EStyleSheet.value("$defaultActivityIndicatorAndroid") : EStyleSheet.value("$defaultActivityIndicatorIOS")} />
  1858.             </View>
  1859.           </Modal>
  1860.         </SafeAreaView>
  1861.       </DrawerLayout>
  1862.     );
  1863.   }
  1864.  
  1865.   async proceedWithVPNPermission() {
  1866.     this.setState({
  1867.       permissionModal: false
  1868.     });
  1869.  
  1870.     addVPNPopup = false;
  1871.     if (Platform.OS == "ios") {
  1872.       let isVPNConfigAccepted = await conProvider.updateProxyDetailsForIos(true);
  1873.       this.setState({
  1874.         isVPNConfigAccepted: varProvider.enableProxy ? isVPNConfigAccepted : true
  1875.       });
  1876.     } else {
  1877.       setTimeout(async () => {
  1878.         let isVPNConfigAccepted = await conProvider.updateProxyDetailsForAndroid(true);
  1879.         this.setState({
  1880.           isVPNConfigAccepted: isVPNConfigAccepted
  1881.         });
  1882.         if (isVPNConfigAccepted) {
  1883.           this.logVPNEvent(true);
  1884.           AsyncStorage.setItem("isVPNLogged", "true");
  1885.         }
  1886.       }, 1000);
  1887.     }
  1888.   }
  1889.  
  1890.   clearParams() {
  1891.     const { params } = this.props.route;
  1892.     if (params != undefined && !params?.contentType) {
  1893.       console.log("clearParams:::::");
  1894.       params.contentType = null;
  1895.       params.menuItemId = null;
  1896.       params.cTitle = null;
  1897.     }
  1898.   }
  1899.  
  1900.   menuItemPress(item, isClicked) {
  1901.     this.clearParams(); //clear params for deeplink when using other menu item press to avoid re render deeplink tab issue
  1902.     ((item.childMenuItems == null || item.childMenuItems?.length == 0) && item.containsContent) && this.drawer.closeDrawer();
  1903.     if (connection.isConnectedFun()) {
  1904.       item.isExpanded = !item.isExpanded;
  1905.       if (item.containsContent) {
  1906.         this.updateTempList(typeList, item)
  1907.         currentTitle = item.title;
  1908.         menuItemId = item.id; // added currentTiTle to display correct name on top of the content screen when menuitem is pressed
  1909.         if (isClicked)
  1910.           this.logScreenViewEvent(false);
  1911.         var tempFilters = this.state.pubFilters;
  1912.         this.setState({
  1913.           refreshTypes: !this.state.refreshTypes
  1914.         });
  1915.         setTimeout(() => {
  1916.           currentType = item.type;   // changed title to type
  1917.           this.callbackFun(tempFilters);
  1918.         }, 450)
  1919.       } else {
  1920.         this.setState({ refresh: !this.state.refresh })
  1921.       }
  1922.     } else {
  1923.       Toast.showShortCenter(translate("PLEASE_CONNECT"));
  1924.     }
  1925.   }
  1926.  
  1927.   updateTempList = (typeList, item, expandActiveItem) => {
  1928.     if (typeList) {
  1929.       var result = false;
  1930.       for (var i = 0; i < typeList.length; i++) {
  1931.         if (typeList[i].childMenuItems?.length > 0) {
  1932.           result = this.updateTempList(typeList[i].childMenuItems, item)
  1933.           if (result || typeList[i].id === item.id) {
  1934.             typeList[i].active = typeList[i].containsContent || result ? true : false
  1935.             if (expandActiveItem)
  1936.               typeList[i].isExpanded = expandActiveItem
  1937.           }
  1938.           else {
  1939.             typeList[i].active = false
  1940.             typeList[i].isExpanded = false
  1941.           }
  1942.         }
  1943.         else if (typeList[i].id === item.id) {
  1944.           typeList[i].active = true
  1945.           result = true
  1946.         }
  1947.         else {
  1948.           typeList[i].active = false
  1949.           typeList[i].isExpanded = false
  1950.         }
  1951.       }
  1952.       return result;
  1953.     }
  1954.   }
  1955.  
  1956.   onDrawerClose() {
  1957.     // console.log("on drawer close");
  1958.   }
  1959.  
  1960. }