@sunggang/ui-lib 0.4.53 → 0.4.55

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.
@@ -463,6 +463,7 @@ var LiffProvider = function(param) {
463
463
  var _useState5 = _sliced_to_array(React.useState(null), 2), liffProfile = _useState5[0], setLiffProfile = _useState5[1];
464
464
  var _useState6 = _sliced_to_array(React.useState(null), 2), isFriendship = _useState6[0], setFriendship = _useState6[1];
465
465
  var _useState7 = _sliced_to_array(React.useState(null), 2), loginType = _useState7[0], setLoginType = _useState7[1];
466
+ var isProcessingLiffCallback = React.useRef(false);
466
467
  // userInfo 的 localStorage key
467
468
  var userInfoStorageKey = "".concat(localStorageKey, "-userInfo");
468
469
  // liff profile 的 localStorage key
@@ -794,6 +795,11 @@ var LiffProvider = function(param) {
794
795
  originalFetch = window.fetch;
795
796
  window.fetch = customFetch;
796
797
  if (openInApp && !(liff === null || liff === void 0 ? void 0 : liff.isInClient()) && (liff === null || liff === void 0 ? void 0 : liff.getOS()) !== "web") window.location.href = "line://app/".concat(liffId);
798
+ if (isProcessingLiffCallback.current) {
799
+ return [
800
+ 2
801
+ ];
802
+ }
797
803
  return [
798
804
  4,
799
805
  liff.init({
@@ -804,6 +810,7 @@ var LiffProvider = function(param) {
804
810
  case 2:
805
811
  _state.sent();
806
812
  console.log("LIFF init succeeded.");
813
+ isProcessingLiffCallback.current = true;
807
814
  setLiffObject(liff);
808
815
  // 如果 localStorage 或 state 已有 profile,就跳過重複呼叫
809
816
  storedProfileExists = false;
@@ -811,6 +818,7 @@ var LiffProvider = function(param) {
811
818
  storedProfileExists = !!window.localStorage.getItem(liffUserInfoStorageKey);
812
819
  } catch (e) {
813
820
  storedProfileExists = false;
821
+ isProcessingLiffCallback.current = false;
814
822
  }
815
823
  if (!(!storedProfileExists && !liffProfile)) return [
816
824
  3,
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { createContext, useState, useCallback, useEffect, useMemo, useContext } from 'react';
2
+ import { createContext, useState, useRef, useCallback, useEffect, useMemo, useContext } from 'react';
3
3
 
4
4
  function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
5
5
  try {
@@ -459,6 +459,7 @@ var LiffProvider = function(param) {
459
459
  var _useState5 = _sliced_to_array(useState(null), 2), liffProfile = _useState5[0], setLiffProfile = _useState5[1];
460
460
  var _useState6 = _sliced_to_array(useState(null), 2), isFriendship = _useState6[0], setFriendship = _useState6[1];
461
461
  var _useState7 = _sliced_to_array(useState(null), 2), loginType = _useState7[0], setLoginType = _useState7[1];
462
+ var isProcessingLiffCallback = useRef(false);
462
463
  // userInfo 的 localStorage key
463
464
  var userInfoStorageKey = "".concat(localStorageKey, "-userInfo");
464
465
  // liff profile 的 localStorage key
@@ -790,6 +791,11 @@ var LiffProvider = function(param) {
790
791
  originalFetch = window.fetch;
791
792
  window.fetch = customFetch;
792
793
  if (openInApp && !(liff === null || liff === void 0 ? void 0 : liff.isInClient()) && (liff === null || liff === void 0 ? void 0 : liff.getOS()) !== "web") window.location.href = "line://app/".concat(liffId);
794
+ if (isProcessingLiffCallback.current) {
795
+ return [
796
+ 2
797
+ ];
798
+ }
793
799
  return [
794
800
  4,
795
801
  liff.init({
@@ -800,6 +806,7 @@ var LiffProvider = function(param) {
800
806
  case 2:
801
807
  _state.sent();
802
808
  console.log("LIFF init succeeded.");
809
+ isProcessingLiffCallback.current = true;
803
810
  setLiffObject(liff);
804
811
  // 如果 localStorage 或 state 已有 profile,就跳過重複呼叫
805
812
  storedProfileExists = false;
@@ -807,6 +814,7 @@ var LiffProvider = function(param) {
807
814
  storedProfileExists = !!window.localStorage.getItem(liffUserInfoStorageKey);
808
815
  } catch (e) {
809
816
  storedProfileExists = false;
817
+ isProcessingLiffCallback.current = false;
810
818
  }
811
819
  if (!(!storedProfileExists && !liffProfile)) return [
812
820
  3,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunggang/ui-lib",
3
- "version": "0.4.53",
3
+ "version": "0.4.55",
4
4
  "sideEffects": [
5
5
  "*.css",
6
6
  "./src/style.css",