fix: Incorrect strings and logics (#1619)

This commit is contained in:
aAbed 2024-01-12 04:00:37 +05:45 committed by GitHub
parent 0d45fe4a97
commit 4f22e88e42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 19 deletions

View file

@ -52,12 +52,12 @@ class ManagerAPI {
String? integrationsVersion = ''; String? integrationsVersion = '';
bool isDefaultPatchesRepo() { bool isDefaultPatchesRepo() {
return getPatchesRepo().toLowerCase() == 'revanced/revanced-patches'; return getPatchesRepo().toLowerCase() == defaultPatchesRepo;
} }
bool isDefaultIntegrationsRepo() { bool isDefaultIntegrationsRepo() {
return getIntegrationsRepo().toLowerCase() == return getIntegrationsRepo().toLowerCase() ==
'revanced/revanced-integrations'; defaultIntegrationsRepo;
} }
Future<void> initialize() async { Future<void> initialize() async {

View file

@ -32,7 +32,7 @@ class RevancedAPI {
final response = await _dio.get('/contributors'); final response = await _dio.get('/contributors');
final List<dynamic> repositories = response.data['repositories']; final List<dynamic> repositories = response.data['repositories'];
for (final Map<String, dynamic> repo in repositories) { for (final Map<String, dynamic> repo in repositories) {
final String name = repo['name']; final String name = repo['name'].toLowerCase();
contributors[name] = repo['contributors']; contributors[name] = repo['contributors'];
} }
} on Exception catch (e) { } on Exception catch (e) {
@ -54,7 +54,7 @@ class RevancedAPI {
final List<dynamic> tools = response.data['tools']; final List<dynamic> tools = response.data['tools'];
return tools.firstWhereOrNull( return tools.firstWhereOrNull(
(t) => (t) =>
t['repository'] == repoName && (t['repository'] as String).toLowerCase() == repoName.toLowerCase() &&
(t['name'] as String).endsWith(extension), (t['name'] as String).endsWith(extension),
); );
} on Exception catch (e) { } on Exception catch (e) {

View file

@ -14,9 +14,9 @@ class ContributorsViewModel extends BaseViewModel {
final Map<String, List<dynamic>> contributors = final Map<String, List<dynamic>> contributors =
await _managerAPI.getContributors(); await _managerAPI.getContributors();
patcherContributors = contributors[_managerAPI.defaultPatcherRepo] ?? []; patcherContributors = contributors[_managerAPI.defaultPatcherRepo] ?? [];
patchesContributors = contributors[_managerAPI.getPatchesRepo()] ?? []; patchesContributors = contributors[_managerAPI.getPatchesRepo().toLowerCase()] ?? [];
integrationsContributors = integrationsContributors =
contributors[_managerAPI.getIntegrationsRepo()] ?? []; contributors[_managerAPI.getIntegrationsRepo().toLowerCase()] ?? [];
cliContributors = contributors[_managerAPI.defaultCliRepo] ?? []; cliContributors = contributors[_managerAPI.defaultCliRepo] ?? [];
managerContributors = contributors[_managerAPI.defaultManagerRepo] ?? []; managerContributors = contributors[_managerAPI.defaultManagerRepo] ?? [];
notifyListeners(); notifyListeners();

View file

@ -40,12 +40,11 @@ class HomeViewModel extends BaseViewModel {
Future<void> initialize(BuildContext context) async { Future<void> initialize(BuildContext context) async {
_managerAPI.rePatchedSavedApps().then((_) => _getPatchedApps()); _managerAPI.rePatchedSavedApps().then((_) => _getPatchedApps());
_latestManagerVersion = await _managerAPI.getLatestManagerVersion();
if (!_managerAPI.getPatchesConsent()) { if (!_managerAPI.getPatchesConsent()) {
await showPatchesConsent(context); await showPatchesConsent(context);
} }
_latestManagerVersion = await _managerAPI.getLatestManagerVersion();
await _patcherAPI.initialize(); await _patcherAPI.initialize();
await flutterLocalNotificationsPlugin.initialize( await flutterLocalNotificationsPlugin.initialize(

View file

@ -43,7 +43,10 @@ class SManageApiUrl extends BaseViewModel {
color: Theme.of(context).colorScheme.onSurfaceVariant, color: Theme.of(context).colorScheme.onSurfaceVariant,
), ),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
labelText: I18nText('settingsView.selectApiURL').toString(), labelText: FlutterI18n.translate(
context,
'settingsView.selectApiURL',
),
hintText: apiUrl, hintText: apiUrl,
), ),
), ),

View file

@ -58,9 +58,10 @@ class SManageSources extends BaseViewModel {
color: Theme.of(context).colorScheme.onSurfaceVariant, color: Theme.of(context).colorScheme.onSurfaceVariant,
), ),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
labelText: I18nText( labelText: FlutterI18n.translate(
context,
'settingsView.hostRepositoryLabel', 'settingsView.hostRepositoryLabel',
).toString(), ),
hintText: hostRepository, hintText: hostRepository,
), ),
), ),
@ -76,9 +77,10 @@ class SManageSources extends BaseViewModel {
color: Theme.of(context).colorScheme.onSurfaceVariant, color: Theme.of(context).colorScheme.onSurfaceVariant,
), ),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
labelText: I18nText( labelText: FlutterI18n.translate(
context,
'settingsView.orgPatchesLabel', 'settingsView.orgPatchesLabel',
).toString(), ),
hintText: patchesRepo.split('/')[0], hintText: patchesRepo.split('/')[0],
), ),
), ),
@ -94,9 +96,10 @@ class SManageSources extends BaseViewModel {
color: Colors.transparent, color: Colors.transparent,
), ),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
labelText: I18nText( labelText: FlutterI18n.translate(
context,
'settingsView.sourcesPatchesLabel', 'settingsView.sourcesPatchesLabel',
).toString(), ),
hintText: patchesRepo.split('/')[1], hintText: patchesRepo.split('/')[1],
), ),
), ),
@ -112,9 +115,10 @@ class SManageSources extends BaseViewModel {
color: Theme.of(context).colorScheme.onSurfaceVariant, color: Theme.of(context).colorScheme.onSurfaceVariant,
), ),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
labelText: I18nText( labelText: FlutterI18n.translate(
context,
'settingsView.orgIntegrationsLabel', 'settingsView.orgIntegrationsLabel',
).toString(), ),
hintText: integrationsRepo.split('/')[0], hintText: integrationsRepo.split('/')[0],
), ),
), ),
@ -130,9 +134,10 @@ class SManageSources extends BaseViewModel {
color: Colors.transparent, color: Colors.transparent,
), ),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
labelText: I18nText( labelText: FlutterI18n.translate(
context,
'settingsView.sourcesIntegrationsLabel', 'settingsView.sourcesIntegrationsLabel',
).toString(), ),
hintText: integrationsRepo.split('/')[1], hintText: integrationsRepo.split('/')[1],
), ),
), ),