fix:修正所有礼物缓存问题
This commit is contained in:
@@ -46,8 +46,10 @@
|
||||
- (void)preLoadGifts {
|
||||
[Api requestAllTagsAndNormalGifts:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200 && data.data) {
|
||||
[[XPGiftStorage shareStorage] cacheTagsWith:data.data
|
||||
inRoom:[[XPGiftStorage shareStorage] defaultKey]];
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
[[XPGiftStorage shareStorage] cacheTagsWith:data.data
|
||||
inRoom:[[XPGiftStorage shareStorage] defaultKey]];
|
||||
});
|
||||
}
|
||||
} roomUid:@""];
|
||||
}
|
||||
|
@@ -179,23 +179,15 @@
|
||||
/// 获取普通的礼物
|
||||
/// @param roomUid 房主的uid 获取房间专属礼物
|
||||
- (void)getNormalGiftList:(NSString *)roomUid {
|
||||
// return;
|
||||
///先不请求接口 从缓存中获取
|
||||
// CGFloat delayDuration = 0.0;
|
||||
// NSArray *giftCacheArray = [[XPGiftStorage shareStorage] getGiftPanelTagsDatasource:roomUid];
|
||||
// if (giftCacheArray.count > 0) {
|
||||
// delayDuration = 0.25;
|
||||
// }
|
||||
|
||||
|
||||
// 进房时先 load 一次最新数据
|
||||
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayDuration * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
|
||||
[Api requestAllTagsAndNormalGifts:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200 && data.data) {
|
||||
// [[XPGiftStorage shareStorage] cacheWith:data.data inRoom:roomUid];
|
||||
[[XPGiftStorage shareStorage] cacheTagsWith:data.data inRoom:roomUid];
|
||||
}
|
||||
} roomUid:roomUid];
|
||||
// });
|
||||
[[XPGiftStorage shareStorage] updateRoomUID:roomUid];
|
||||
|
||||
[Api requestAllTagsAndNormalGifts:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200 && data.data) {
|
||||
[[XPGiftStorage shareStorage] cacheTagsWith:data.data inRoom:roomUid];
|
||||
}
|
||||
} roomUid:roomUid];
|
||||
}
|
||||
|
||||
/// 上报用户进房
|
||||
|
@@ -31,7 +31,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param giftId 礼物的id
|
||||
- (GiftInfoModel *)findGiftInfo:(NSString *)giftId;
|
||||
|
||||
//- (NSArray *)cacheWith:(NSDictionary *)response inRoom:(NSString *)roomUid;
|
||||
// 进房时需要主动更新 roomID,礼物 model 会优先从对应的
|
||||
- (void)updateRoomUID:(NSString *)roomUID;
|
||||
|
||||
- (NSArray *)cacheTagsWith:(NSDictionary *)response inRoom:(NSString *)roomUid;
|
||||
|
||||
@end
|
||||
|
@@ -132,10 +132,14 @@
|
||||
return _roomGiftPanelTagsCache;
|
||||
}
|
||||
|
||||
- (void)updateRoomUID:(NSString *)roomUID
|
||||
{
|
||||
self.currentRoomUid = roomUID;
|
||||
}
|
||||
|
||||
///處理 API 數據,分別緩存所有禮物和 tab/tab禮物
|
||||
- (NSArray *)cacheTagsWith:(NSDictionary *)response inRoom:(NSString *)roomUid {
|
||||
NSArray *tabModels = [GiftPanelTabModel modelsWithArray:response[@"tabList"]];
|
||||
[self saveGiftPanelTagsDatasource:tabModels roomUid:roomUid];
|
||||
|
||||
NSDictionary *contents = response;
|
||||
if ([[response allKeys] containsObject:@"giftTabMap"]) {
|
||||
@@ -144,21 +148,29 @@
|
||||
|
||||
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"seq" ascending:YES];
|
||||
NSMutableArray <GiftPanelTabModel *>*mutableTabs = [tabModels sortedArrayUsingDescriptors:@[sortDescriptor]].mutableCopy;
|
||||
NSMutableArray *totalInfo = [NSMutableArray array];
|
||||
|
||||
// 构建每个 Tab 下的礼物
|
||||
for (GiftPanelTabModel *model in mutableTabs) {
|
||||
NSString *key = model.key;
|
||||
NSArray *giftsArray = [contents objectForKey:key];
|
||||
if (giftsArray.count > 0) {
|
||||
NSArray *giftModels = [GiftInfoModel modelsWithArray:giftsArray];
|
||||
model.gifts = giftModels;
|
||||
[totalInfo addObjectsFromArray:giftModels];
|
||||
}
|
||||
}
|
||||
|
||||
// 所有礼物,福袋爆出的礼物会从这里获取
|
||||
NSMutableArray *totalInfo = [NSMutableArray array];
|
||||
for (NSString *key in contents) {
|
||||
NSArray *giftModels = [GiftInfoModel modelsWithArray:[contents objectForKey:key]];
|
||||
[totalInfo addObjectsFromArray:giftModels];
|
||||
}
|
||||
|
||||
[self saveGiftDatasource:totalInfo roomUid:roomUid];
|
||||
[self saveGiftPanelTagsDatasource:mutableTabs roomUid:roomUid];
|
||||
|
||||
self.currentRoomUid = roomUid;
|
||||
|
||||
return mutableTabs;
|
||||
}
|
||||
|
||||
|
@@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
///关闭webView 目前适用于半屏的情况下
|
||||
@property (nonatomic,copy) void (^CloseWebViewBlock)(BOOL result);
|
||||
- (instancetype)initWithCustomizeNav:(BOOL)isCustom;
|
||||
- (instancetype)initWithGame;
|
||||
//- (instancetype)initWithGame;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -72,7 +72,7 @@ typedef NS_ENUM(NSUInteger, RightNavigationPushType){
|
||||
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
|
||||
|
||||
if ([self.scriptDelegate respondsToSelector:@selector(userContentController:didReceiveScriptMessage:)]) {
|
||||
[self.scriptDelegate userContentController:userContentController didReceiveScriptMessage:message];
|
||||
[self.scriptDelegate userContentController:userContentController didReceiveScriptMessage:message];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ NSString * const kJSOpenPaymentCallback = @"openPaymentCallback";
|
||||
}
|
||||
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler{
|
||||
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];
|
||||
completionHandler(NSURLSessionAuthChallengeUseCredential,card);
|
||||
});
|
||||
@@ -314,7 +314,6 @@ NSString * const kJSOpenPaymentCallback = @"openPaymentCallback";
|
||||
NSLog(@"-- -- - -- - -%@: %@", message.name, message.body);
|
||||
NSString *currentUrl = [NSString stringWithFormat:@"%@", response];
|
||||
///测试环境只要有host就执行,方便h5连接本地调试
|
||||
|
||||
BOOL condition = currentUrl != nil && [currentUrl containsString:API_HOST_URL];
|
||||
#ifdef DEBUG
|
||||
condition = currentUrl != nil;
|
||||
@@ -1051,10 +1050,12 @@ NSString * const kJSOpenPaymentCallback = @"openPaymentCallback";
|
||||
}
|
||||
return _navView;
|
||||
}
|
||||
- (PIWebViewSavePhotoView *)saveView{
|
||||
if(!_saveView){
|
||||
_saveView = [[PIWebViewSavePhotoView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||||
}
|
||||
return _saveView;
|
||||
- (PIWebViewSavePhotoView *)saveView{
|
||||
if(!_saveView){
|
||||
_saveView = [[PIWebViewSavePhotoView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||||
}
|
||||
return _saveView;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user