Browse Source

refactor(neon): User agent handling

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/538/head
jld3103 1 year ago
parent
commit
d802d7df0c
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 11
      packages/neon/neon/lib/neon.dart
  2. 2
      packages/neon/neon/lib/src/blocs/login_check_account.dart
  3. 2
      packages/neon/neon/lib/src/blocs/login_check_server_status.dart
  4. 2
      packages/neon/neon/lib/src/blocs/login_flow.dart
  5. 15
      packages/neon/neon/lib/src/utils/user_agent.dart

11
packages/neon/neon/lib/neon.dart

@ -2,7 +2,6 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:meta/meta.dart';
import 'package:neon/src/app.dart';
import 'package:neon/src/blocs/accounts.dart';
import 'package:neon/src/blocs/first_launch.dart';
@ -14,13 +13,11 @@ import 'package:neon/src/platform/platform.dart';
import 'package:neon/src/theme/neon.dart';
import 'package:neon/src/utils/global_options.dart';
import 'package:neon/src/utils/request_manager.dart';
import 'package:neon/src/utils/user_agent.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
@internal
late final String neonUserAgent;
Future runNeon({
required final Iterable<AppImplementation> Function(SharedPreferences, RequestManager, NeonPlatform)
getAppImplementations,
@ -43,11 +40,7 @@ Future runNeon({
final allAppImplementations = getAppImplementations(sharedPreferences, requestManager, platform);
final packageInfo = await PackageInfo.fromPlatform();
var buildNumber = packageInfo.buildNumber;
if (buildNumber.isEmpty) {
buildNumber = '1';
}
neonUserAgent = 'Neon ${packageInfo.version}+$buildNumber';
buildUserAgent(packageInfo);
final globalOptions = GlobalOptions(
sharedPreferences,

2
packages/neon/neon/lib/src/blocs/login_check_account.dart

@ -1,10 +1,10 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:neon/neon.dart';
import 'package:neon/src/bloc/bloc.dart';
import 'package:neon/src/bloc/result.dart';
import 'package:neon/src/models/account.dart';
import 'package:neon/src/utils/user_agent.dart';
import 'package:nextcloud/nextcloud.dart';
import 'package:rxdart/rxdart.dart';

2
packages/neon/neon/lib/src/blocs/login_check_server_status.dart

@ -1,9 +1,9 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:neon/neon.dart';
import 'package:neon/src/bloc/bloc.dart';
import 'package:neon/src/bloc/result.dart';
import 'package:neon/src/utils/user_agent.dart';
import 'package:nextcloud/nextcloud.dart';
import 'package:rxdart/rxdart.dart';

2
packages/neon/neon/lib/src/blocs/login_flow.dart

@ -1,9 +1,9 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:neon/neon.dart';
import 'package:neon/src/bloc/bloc.dart';
import 'package:neon/src/bloc/result.dart';
import 'package:neon/src/utils/user_agent.dart';
import 'package:nextcloud/nextcloud.dart';
import 'package:rxdart/rxdart.dart';

15
packages/neon/neon/lib/src/utils/user_agent.dart

@ -0,0 +1,15 @@
import 'package:meta/meta.dart';
import 'package:package_info_plus/package_info_plus.dart';
late String? _userAgent;
void buildUserAgent(final PackageInfo packageInfo) {
var buildNumber = packageInfo.buildNumber;
if (buildNumber.isEmpty) {
buildNumber = '1';
}
_userAgent = 'Neon ${packageInfo.version}+$buildNumber';
}
@internal
String get neonUserAgent => _userAgent!;
Loading…
Cancel
Save