1
This commit is contained in:
@@ -10,9 +10,11 @@
|
|||||||
#import "IAPVerifyTransactionObj.h"
|
#import "IAPVerifyTransactionObj.h"
|
||||||
#import "KBAPI.h"
|
#import "KBAPI.h"
|
||||||
#import "KBUser.h"
|
#import "KBUser.h"
|
||||||
|
#import "KBMyVM.h"
|
||||||
|
|
||||||
@interface KBLoginVM ()
|
@interface KBLoginVM ()
|
||||||
@property (atomic, strong, readwrite, nullable) KBUser *currentUser;
|
@property (atomic, strong, readwrite, nullable) KBUser *currentUser;
|
||||||
|
@property (nonatomic, strong) KBMyVM *myVM;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation KBLoginVM
|
@implementation KBLoginVM
|
||||||
@@ -75,6 +77,7 @@
|
|||||||
}
|
}
|
||||||
[[KBUserSessionManager shared] handleLoginSuccessWithUser:user];
|
[[KBUserSessionManager shared] handleLoginSuccessWithUser:user];
|
||||||
[KBLoginVM kb_configureIAPIfNeeded];
|
[KBLoginVM kb_configureIAPIfNeeded];
|
||||||
|
[self kb_syncKeyboardCharactersAfterLogin];
|
||||||
if (completion) completion(YES, nil);
|
if (completion) completion(YES, nil);
|
||||||
// 保存登录态到共享钥匙串;供 App 与扩展共享
|
// 保存登录态到共享钥匙串;供 App 与扩展共享
|
||||||
// BOOL ok = [[KBAuthManager shared] saveAccessToken:user.token
|
// BOOL ok = [[KBAuthManager shared] saveAccessToken:user.token
|
||||||
@@ -111,6 +114,7 @@
|
|||||||
}
|
}
|
||||||
[[KBUserSessionManager shared] handleLoginSuccessWithUser:user];
|
[[KBUserSessionManager shared] handleLoginSuccessWithUser:user];
|
||||||
[KBLoginVM kb_configureIAPIfNeeded];
|
[KBLoginVM kb_configureIAPIfNeeded];
|
||||||
|
[self kb_syncKeyboardCharactersAfterLogin];
|
||||||
if (completion) completion(YES, nil);
|
if (completion) completion(YES, nil);
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@@ -172,6 +176,21 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
|
- (void)kb_syncKeyboardCharactersAfterLogin {
|
||||||
|
if (!self.myVM) {
|
||||||
|
self.myVM = [[KBMyVM alloc] init];
|
||||||
|
}
|
||||||
|
[self.myVM fetchCharacterListByUserWithCompletion:^(NSArray<KBCharacter *> * _Nonnull characterArray, NSError * _Nullable error) {
|
||||||
|
if (error) {
|
||||||
|
KBLOG(@"[Login] Failed to sync keyboard characters after login: %@", error);
|
||||||
|
} else {
|
||||||
|
KBLOG(@"[Login] Synced %tu keyboard characters after login", characterArray.count);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Helpers
|
#pragma mark - Helpers
|
||||||
|
|
||||||
// 宽松解析:token / access_token / accessToken,支持顶层或 data/user 层
|
// 宽松解析:token / access_token / accessToken,支持顶层或 data/user 层
|
||||||
|
|||||||
Reference in New Issue
Block a user