Skip to content

Commit

Permalink
Release 2.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
王洋洋 committed May 29, 2023
1 parent dcd2cc3 commit 85b119f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion RNSensorsAnalyticsModule.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "RNSensorsAnalyticsModule"
s.version = "2.3.5"
s.version = "2.3.6"
s.summary = "The official React Native SDK of Sensors Analytics."
s.description = <<-DESC
神策分析 RN 组件
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.List;

public class RNSensorsAnalyticsPackage implements ReactPackage {
public static final String VERSION = "2.3.5";
public static final String VERSION = "2.3.6";

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
Expand Down
2 changes: 1 addition & 1 deletion ios/RNSensorsAnalyticsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#import "SAReactNativeManager.h"
#import "SAReactNativeEventProperty.h"

NSString *const kSAReactNativePluginVersion = @"react_native:2.3.5";
NSString *const kSAReactNativePluginVersion = @"react_native:2.3.6";

@implementation RNSensorsAnalyticsModule

Expand Down
45 changes: 31 additions & 14 deletions ios/SAReactNativeRootViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@
#import "SAReactNativeRootViewManager.h"
#import <React/RCTUIManager.h>

void sensors_reactnative_dispatch_safe_sync(dispatch_queue_t queue,DISPATCH_NOESCAPE dispatch_block_t block) {
if ((dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)) == dispatch_queue_get_label(queue)) {
block();
} else {
dispatch_sync(queue, block);
}
}

@interface SAReactNativeRootViewManager ()

@property (nonatomic, strong) NSPointerArray *rootViews;
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSMutableSet *> *viewProperties;
@property (nonatomic, strong) dispatch_queue_t serialQueue;

@end

Expand All @@ -44,6 +53,7 @@ - (instancetype)init {
if (self) {
_rootViews = [NSPointerArray weakObjectsPointerArray];
_viewProperties = [NSMutableDictionary dictionary];
_serialQueue = dispatch_queue_create("cn.SensorsData.SAReactNativeRootViewManagerQueue", DISPATCH_QUEUE_SERIAL);
}
return self;
}
Expand Down Expand Up @@ -76,20 +86,25 @@ - (void)addViewProperty:(SAReactNativeViewProperty *)property withRootTag:(NSNum
return;
}

NSMutableSet *viewProperties = self.viewProperties[rootTag];
if (!viewProperties) {
viewProperties = [NSMutableSet set];
self.viewProperties[rootTag] = viewProperties;
}
[viewProperties addObject:property];
sensors_reactnative_dispatch_safe_sync(self.serialQueue, ^{
NSMutableSet *viewProperties = self.viewProperties[rootTag];
if (!viewProperties) {
viewProperties = [NSMutableSet set];
self.viewProperties[rootTag] = viewProperties;
}
[viewProperties addObject:property];
});
}

- (NSSet<SAReactNativeViewProperty *> *)viewPropertiesWithRootTag:(NSNumber *)rootTag {
NSSet *viewProperties = self.viewProperties[rootTag];
if (!viewProperties) {
return nil;
}
return [[NSSet alloc] initWithSet:viewProperties copyItems:YES];
__block NSSet *viewProperties = nil;
sensors_reactnative_dispatch_safe_sync(self.serialQueue, ^{
NSSet *tempProperties = self.viewProperties[rootTag];
if (tempProperties) {
viewProperties = [[NSSet alloc] initWithSet:tempProperties copyItems:YES];
}
});
return viewProperties;
}

#pragma mark - utils
Expand All @@ -109,9 +124,11 @@ - (void)compact {
[rootTags addObject:rootView.reactTag];
}

NSMutableSet *removeTags = [NSMutableSet setWithArray:[self.viewProperties allKeys]];
[removeTags minusSet:rootTags];
[self.viewProperties removeObjectsForKeys:removeTags.allObjects];
sensors_reactnative_dispatch_safe_sync(self.serialQueue, ^{
NSMutableSet *removeTags = [NSMutableSet setWithArray:[self.viewProperties allKeys]];
[removeTags minusSet:rootTags];
[self.viewProperties removeObjectsForKeys:removeTags.allObjects];
});
}

@end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sensorsdata-analytics-react-native",
"version": "2.3.5",
"version": "2.3.6",
"private": false,
"description": "神策分析 RN 组件",
"main": "index.js",
Expand Down

0 comments on commit 85b119f

Please sign in to comment.