refactor: formatting
This commit is contained in:
@@ -15,7 +15,9 @@ class TokenValidator {
|
||||
}
|
||||
|
||||
// Check if it's an API key format (starts with sk- or similar)
|
||||
if (token.startsWith('sk-') || token.startsWith('api-') || token.startsWith('key-')) {
|
||||
if (token.startsWith('sk-') ||
|
||||
token.startsWith('api-') ||
|
||||
token.startsWith('key-')) {
|
||||
// API key format - validate differently
|
||||
if (token.length < 20) {
|
||||
return TokenValidationResult.invalid('API key too short');
|
||||
|
||||
@@ -22,17 +22,23 @@ sealed class Folder with _$Folder {
|
||||
// Extract conversation IDs from items.chats if available
|
||||
final items = json['items'] as Map<String, dynamic>?;
|
||||
final chats = items?['chats'] as List?;
|
||||
|
||||
|
||||
// Handle both string IDs and conversation objects
|
||||
final conversationIds = chats?.map((chat) {
|
||||
if (chat is String) {
|
||||
return chat;
|
||||
} else if (chat is Map<String, dynamic>) {
|
||||
return chat['id'] as String? ?? '';
|
||||
}
|
||||
return '';
|
||||
}).where((id) => id.isNotEmpty).toList().cast<String>() ?? <String>[];
|
||||
|
||||
final conversationIds =
|
||||
chats
|
||||
?.map((chat) {
|
||||
if (chat is String) {
|
||||
return chat;
|
||||
} else if (chat is Map<String, dynamic>) {
|
||||
return chat['id'] as String? ?? '';
|
||||
}
|
||||
return '';
|
||||
})
|
||||
.where((id) => id.isNotEmpty)
|
||||
.toList()
|
||||
.cast<String>() ??
|
||||
<String>[];
|
||||
|
||||
// Handle Unix timestamp conversion
|
||||
DateTime? parseTimestamp(dynamic timestamp) {
|
||||
if (timestamp == null) return null;
|
||||
@@ -44,7 +50,7 @@ sealed class Folder with _$Folder {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Create the modified JSON with proper field mapping
|
||||
return Folder(
|
||||
id: json['id'] as String,
|
||||
|
||||
@@ -23,4 +23,4 @@ sealed class Tool with _$Tool {
|
||||
meta: json['meta'] as Map<String, dynamic>?,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ class InputValidationService {
|
||||
|
||||
try {
|
||||
final uri = Uri.parse(urlToValidate);
|
||||
|
||||
|
||||
// Validate scheme
|
||||
if (!uri.hasScheme || (uri.scheme != 'http' && uri.scheme != 'https')) {
|
||||
return 'Use http:// or https:// only';
|
||||
}
|
||||
|
||||
|
||||
// Validate host
|
||||
if (!uri.hasAuthority || uri.host.isEmpty) {
|
||||
return 'Please enter a server address (e.g., 192.168.1.10:3000)';
|
||||
@@ -65,7 +65,6 @@ class InputValidationService {
|
||||
if (_isIPAddress(uri.host) && !_isValidIPAddress(uri.host)) {
|
||||
return 'Invalid IP address format (use 192.168.1.10)';
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
return 'Invalid server address format';
|
||||
}
|
||||
@@ -82,7 +81,7 @@ class InputValidationService {
|
||||
static bool _isValidIPAddress(String ip) {
|
||||
final parts = ip.split('.');
|
||||
if (parts.length != 4) return false;
|
||||
|
||||
|
||||
for (final part in parts) {
|
||||
final num = int.tryParse(part);
|
||||
if (num == null || num < 0 || num > 255) return false;
|
||||
|
||||
@@ -16,7 +16,9 @@ class OptimizedStorageService {
|
||||
required FlutterSecureStorage secureStorage,
|
||||
required SharedPreferences prefs,
|
||||
}) : _prefs = prefs,
|
||||
_secureCredentialStorage = SecureCredentialStorage(instance: secureStorage);
|
||||
_secureCredentialStorage = SecureCredentialStorage(
|
||||
instance: secureStorage,
|
||||
);
|
||||
|
||||
// Optimized key names with versioning
|
||||
static const String _authTokenKey = 'auth_token_v3';
|
||||
|
||||
@@ -74,7 +74,9 @@ class PersistentStreamingService with WidgetsBindingObserver {
|
||||
|
||||
_connectivitySubscription?.cancel();
|
||||
_connectivityService = service;
|
||||
_connectivitySubscription = service.isConnected.listen(_handleConnectivityChange);
|
||||
_connectivitySubscription = service.isConnected.listen(
|
||||
_handleConnectivityChange,
|
||||
);
|
||||
}
|
||||
|
||||
void _handleConnectivityChange(bool connected) {
|
||||
|
||||
@@ -336,10 +336,12 @@ class PlatformService {
|
||||
// on Android 15+. Only control icon brightness; colors come from theme + EdgeToEdge.
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
SystemUiOverlayStyle(
|
||||
statusBarIconBrightness:
|
||||
isDarkContent ? Brightness.dark : Brightness.light,
|
||||
systemNavigationBarIconBrightness:
|
||||
isDarkContent ? Brightness.dark : Brightness.light,
|
||||
statusBarIconBrightness: isDarkContent
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
systemNavigationBarIconBrightness: isDarkContent
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
// Do NOT set status/navigation bar colors on Android.
|
||||
),
|
||||
);
|
||||
|
||||
@@ -9,10 +9,12 @@ class SecureCredentialStorage {
|
||||
late final FlutterSecureStorage _secureStorage;
|
||||
|
||||
SecureCredentialStorage({FlutterSecureStorage? instance}) {
|
||||
_secureStorage = instance ?? FlutterSecureStorage(
|
||||
aOptions: _getAndroidOptions(),
|
||||
iOptions: _getIOSOptions(),
|
||||
);
|
||||
_secureStorage =
|
||||
instance ??
|
||||
FlutterSecureStorage(
|
||||
aOptions: _getAndroidOptions(),
|
||||
iOptions: _getIOSOptions(),
|
||||
);
|
||||
}
|
||||
|
||||
static const String _credentialsKey = 'user_credentials_v2';
|
||||
|
||||
@@ -16,7 +16,9 @@ class StorageService {
|
||||
required SharedPreferences prefs,
|
||||
}) : _secureStorage = secureStorage,
|
||||
_prefs = prefs,
|
||||
_secureCredentialStorage = SecureCredentialStorage(instance: secureStorage);
|
||||
_secureCredentialStorage = SecureCredentialStorage(
|
||||
instance: secureStorage,
|
||||
);
|
||||
|
||||
// Secure storage keys
|
||||
static const String _authTokenKey = 'auth_token';
|
||||
|
||||
@@ -26,4 +26,4 @@ final toolsServiceProvider = Provider<ToolsService?>((ref) {
|
||||
final apiService = ref.watch(apiServiceProvider);
|
||||
if (apiService == null) return null;
|
||||
return ToolsService(apiService);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,8 +10,8 @@ class InactivityWatchdog {
|
||||
required Duration window,
|
||||
required this.onTimeout,
|
||||
Duration? absoluteCap,
|
||||
}) : _window = window,
|
||||
_absoluteCap = absoluteCap;
|
||||
}) : _window = window,
|
||||
_absoluteCap = absoluteCap;
|
||||
|
||||
final void Function() onTimeout;
|
||||
|
||||
@@ -80,4 +80,3 @@ class InactivityWatchdog {
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user