Skip to content

Commit

Permalink
Upgrade swift dependency, add support for invalidate function
Browse files Browse the repository at this point in the history
  • Loading branch information
markmur committed Oct 24, 2024
1 parent f5e67e5 commit cf0968e
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Pod::Spec.new do |s|
s.source_files = "ios/*.{h,m,mm,swift}"

s.dependency "React-Core"
s.dependency "ShopifyCheckoutSheetKit", "~> 3.0.4"
s.dependency "ShopifyCheckoutSheetKit", "~> 3.1.1"

if fabric_enabled
install_modules_dependencies(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ @interface RCT_EXTERN_MODULE(RCTShopifyCheckoutSheetKit, NSObject)
/// Dismiss checkout
RCT_EXTERN_METHOD(dismiss);

/// Invalidate preload cache
RCT_EXTERN_METHOD(invalidateCache);

/// Set configuration for checkout
RCT_EXTERN_METHOD(setConfig:(NSDictionary *)configuration);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
}
}

@objc func invalidateCache() {
ShopifyCheckoutSheetKit.invalidate()
}

@objc func present(_ checkoutURL: String) {
DispatchQueue.main.async {
if let url = URL(string: checkoutURL), let viewController = self.getCurrentViewController() {
Expand Down
8 changes: 8 additions & 0 deletions modules/@shopify/checkout-sheet-kit/src/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface Context {
preload: (checkoutUrl: string) => void;
present: (checkoutUrl: string) => void;
dismiss: () => void;
invalidate: () => void;
version: Maybe<string>;
}

Expand All @@ -54,6 +55,7 @@ const ShopifyCheckoutSheetContext = React.createContext<Context>({
getConfig: async () => undefined,
preload: noop,
present: noop,
invalidate: noop,
dismiss: noop,
version: undefined,
});
Expand Down Expand Up @@ -95,6 +97,10 @@ export function ShopifyCheckoutSheetProvider({
}
}, []);

const invalidate = useCallback(() => {
instance.current?.invalidate();
}, []);

const dismiss = useCallback(() => {
instance.current?.dismiss();
}, []);
Expand All @@ -115,6 +121,7 @@ export function ShopifyCheckoutSheetProvider({
getConfig,
preload,
present,
invalidate,
removeEventListeners,
version: instance.current?.version,
};
Expand All @@ -126,6 +133,7 @@ export function ShopifyCheckoutSheetProvider({
setConfig,
preload,
present,
invalidate,
]);

return (
Expand Down
5 changes: 5 additions & 0 deletions modules/@shopify/checkout-sheet-kit/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ export interface ShopifyCheckoutSheetKit {
* Preload the checkout for faster presentation.
*/
preload(checkoutURL: string): void;

/**
* Invalidate preload cache.
*/
invalidate(): void;
/**
* Present the checkout.
*/
Expand Down
4 changes: 4 additions & 0 deletions modules/@shopify/checkout-sheet-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class ShopifyCheckoutSheet implements ShopifyCheckoutSheetKit {
RNShopifyCheckoutSheetKit.dismiss();
}

public invalidate(): void {
RNShopifyCheckoutSheetKit.invalidateCache();
}

public preload(checkoutUrl: string): void {
RNShopifyCheckoutSheetKit.preload(checkoutUrl);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"clean": "watchman watch-del .",
"sample": "yarn workspace sample",
"module": "yarn workspace @shopify/checkout-sheet-kit",
"pod-install": "(cd sample/ios && bundle exec pod repo update && NO_FLIPPER=1 bundle exec pod install --repo-update)",
"pod-install": "(cd sample/ios && bundle install && bundle exec pod repo update && bundle exec pod cache clean --all && NO_FLIPPER=1 bundle exec pod install --repo-update)",
"snapshot": "./scripts/create_snapshot",
"compare-snapshot": "./scripts/compare_snapshot",
"turbo": "turbo",
Expand Down
2 changes: 1 addition & 1 deletion sample/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ target 'ReactNative' do
end
end

pod 'SwiftLint'
# pod 'SwiftLint'

pod "RNShopifyCheckoutSheetKit", :path => "../../modules/@shopify/checkout-sheet-kit"
16 changes: 6 additions & 10 deletions sample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1235,9 +1235,9 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNShopifyCheckoutSheetKit (3.0.3):
- RNShopifyCheckoutSheetKit (3.0.4):
- React-Core
- ShopifyCheckoutSheetKit (~> 3.0.4)
- ShopifyCheckoutSheetKit (~> 3.1.1)
- RNVectorIcons (10.0.3):
- DoubleConversion
- glog
Expand All @@ -1259,9 +1259,8 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- ShopifyCheckoutSheetKit (3.0.4)
- ShopifyCheckoutSheetKit (3.1.1)
- SocketRocket (0.7.0)
- SwiftLint (0.56.1)
- Yoga (0.0.0)

DEPENDENCIES:
Expand Down Expand Up @@ -1328,14 +1327,12 @@ DEPENDENCIES:
- RNScreens (from `../node_modules/react-native-screens`)
- "RNShopifyCheckoutSheetKit (from `../../modules/@shopify/checkout-sheet-kit`)"
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- SwiftLint
- Yoga (from `../../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
trunk:
- ShopifyCheckoutSheetKit
- SocketRocket
- SwiftLint

EXTERNAL SOURCES:
boost:
Expand Down Expand Up @@ -1524,13 +1521,12 @@ SPEC CHECKSUMS:
RNGestureHandler: 9b113eb9b7a4cbe66e1dbf4d9914281863ee0703
RNReanimated: d534e0114e2c3e7011550a78ecf2d0b431435a60
RNScreens: 23dad53fc9db1da2c93e647ae33fd7ce2bd49d60
RNShopifyCheckoutSheetKit: 3d386855d029ba2a06fa537c9bf1f9057bbc4f6a
RNShopifyCheckoutSheetKit: a1d74986116e1303d7809681310b66c1dfd9c503
RNVectorIcons: 50ea777efffdd991a22e968aa312d75da7ff46c3
ShopifyCheckoutSheetKit: 1753e9a06df41ca567ace784719fd43cff89b872
ShopifyCheckoutSheetKit: fe309799b18b8d554f28c3f075d6d57d4811c9ab
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
SwiftLint: c5fa0b7eece474d43d2178b581a1242a16267347
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372

PODFILE CHECKSUM: 9efd19a381198fb46f36acf3d269233039fb9dc5
PODFILE CHECKSUM: 4a9ceecdcfb54884b51163a7e4438cd49c73c8d9

COCOAPODS: 1.15.2

0 comments on commit cf0968e

Please sign in to comment.