@esvndev/es-react-config-setting 1.0.78 → 1.0.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  import { key_format } from "../../shared/type";
2
2
  export declare const GLOBAL_WINDOW_VARIABLE: Record<string, any>;
3
- export declare const INIT_CONFIG_SETTING: () => void;
3
+ export declare const INIT_CONFIG_SETTING: () => Promise<void>;
4
4
  export declare const get_conf: (key: string, type?: key_format) => any;
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ type key_format = 'text' | 'int' | 'decimal' | 'byte' | 'object';
9
9
 
10
10
  declare const SettingApp: (props: ISettingApp) => react_jsx_runtime.JSX.Element;
11
11
 
12
- declare const INIT_CONFIG_SETTING: () => void;
12
+ declare const INIT_CONFIG_SETTING: () => Promise<void>;
13
13
  declare const get_conf: (key: string, type?: key_format) => any;
14
14
 
15
15
  export { INIT_CONFIG_SETTING, SettingApp, get_conf };
package/dist/index.js CHANGED
@@ -18725,7 +18725,7 @@ const GetSettingGroup = (callback) => {
18725
18725
  callback({ status: false, data: error });
18726
18726
  });
18727
18727
  };
18728
- const GetSettingConfigClient = (callback) => {
18728
+ const GetSettingConfigClient = async (callback) => {
18729
18729
  const _url = `${BASE_URL}/api/config/get-setting-config-client`;
18730
18730
  const _obj = {
18731
18731
  ModuleId: REACT_APP_PRODUCT_CODE,
@@ -18740,7 +18740,7 @@ const GetSettingConfigClient = (callback) => {
18740
18740
  },
18741
18741
  body: JSON.stringify(_obj)
18742
18742
  };
18743
- fetch(_url, options)
18743
+ await fetch(_url, options)
18744
18744
  .then(response => {
18745
18745
  if (!response.ok) {
18746
18746
  console.log(`HTTP error! Status: ${response.status}`);
@@ -19028,12 +19028,15 @@ const VARIABLE_FRIVATE = {
19028
19028
  let intervalId = null;
19029
19029
  var TIME_RELOAD = 15000;
19030
19030
  //Load interval data default
19031
- const INIT_CONFIG_SETTING = () => {
19031
+ const INIT_CONFIG_SETTING = async () => {
19032
19032
  _LOAD_(null);
19033
19033
  if (intervalId) {
19034
19034
  clearInterval(intervalId);
19035
19035
  intervalId = null;
19036
19036
  }
19037
+ if (!localStorage.getItem("app_config_setting_version")) {
19038
+ await _FETCH_AND_UPDATE();
19039
+ }
19037
19040
  intervalId = setInterval(() => {
19038
19041
  _FETCH_AND_UPDATE();
19039
19042
  }, TIME_RELOAD);
@@ -19091,8 +19094,8 @@ const get_conf = (key, type) => {
19091
19094
  }
19092
19095
  return _;
19093
19096
  };
19094
- const _FETCH_AND_UPDATE = () => {
19095
- GetSettingConfigClient((data) => {
19097
+ const _FETCH_AND_UPDATE = async () => {
19098
+ await GetSettingConfigClient((data) => {
19096
19099
  try {
19097
19100
  if (data?.isupdatetime) {
19098
19101
  TIME_RELOAD = (data?.timeupdate < 5000 || data?.timeupdate > 300000) ? 5000 : data?.timeupdate;