This commit is contained in:
2025-12-11 21:00:43 +08:00
parent 35597f89ca
commit 704553cd4e

View File

@@ -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