fix:【MainActivity】自动登录逻辑调整:去掉每次获取ticket的动作(接口并发大概率造成401现象);和后台沟通:现阶段不需要每次刷新即可

This commit is contained in:
Max
2023-11-20 20:03:21 +08:00
parent 345cf1a112
commit 41c00cadcd

View File

@@ -219,20 +219,9 @@ public class AuthModel extends BaseModel implements IAuthModel {
if (currentAccountInfo == null || TextUtils.isEmpty(currentAccountInfo.getAccess_token())) { if (currentAccountInfo == null || TextUtils.isEmpty(currentAccountInfo.getAccess_token())) {
return Single.error(new Throwable(""));//没有账号信息 return Single.error(new Throwable(""));//没有账号信息
} }
return requestTicket().flatMap(ticketResult -> { return imLogin(currentAccountInfo)
if (!ticketResult.isSuccess()) {
return Single.error(new Throwable(ticketResult.getMessage()));
}
ticketInfo = ticketResult.getData();
DemoCache.saveTicketInfo(ticketInfo);
return Single.just(ResUtil.getString(R.string.xchat_android_core_auth_authmodel_01));
})
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.flatMap((Function<String, SingleSource<String>>) s -> {
Log.i("IMLogin", "apply");
return imLogin(currentAccountInfo);
})
.doOnSuccess(s -> { .doOnSuccess(s -> {
EventBus.getDefault().post(new LoginEvent()); EventBus.getDefault().post(new LoginEvent());
}); });