Skip to content

Commit

Permalink
Use Future.doWhile(Function()) instead while (bool)
Browse files Browse the repository at this point in the history
  • Loading branch information
Muska-Ami committed Dec 24, 2024
1 parent a2c87c9 commit 1904057
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions nyalcf_cli/lib/commands/authorize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ import 'dart:io';

// Package imports:
import 'package:crypto/crypto.dart';
// Project imports:
import 'package:nyalcf/templates/command.dart';
import 'package:nyalcf_core/models/user_info_model.dart';
import 'package:nyalcf_core/network/client/api/auth/oauth/access_token.dart';
import 'package:nyalcf_core/network/client/api/user/frp/token.dart'
as user_frp_token;
import 'package:nyalcf_core/network/client/api/user/info.dart' as user_info;
import 'package:nyalcf_core/network/client/api_client.dart';
import 'package:nyalcf_core/network/server/oauth.dart';
import 'package:nyalcf_core/storages/stores/user_info_storage.dart';
import 'package:nyalcf_core/utils/logger.dart';
import 'package:nyalcf_core_extend/storages/token_storage.dart';

// Project imports:
import 'package:nyalcf/templates/command.dart';

import 'package:nyalcf_core/network/client/api/user/frp/token.dart'
as user_frp_token;

class Authorize implements Command {
static final _tokenStorage = TokenStorage();

Expand All @@ -42,7 +40,10 @@ class Authorize implements Command {
'&path=/oauth/callback',
);
Logger.write('Waiting callback...');
while (!_callback) {}
Future.doWhile(() async {
await Future.delayed(const Duration(milliseconds: 1000)); // 延迟检查
return !_callback;
});
if (_refreshToken == null) exit(1);
final rs = await api.post(PostAccessToken(
appId: 1,
Expand Down

0 comments on commit 1904057

Please sign in to comment.