mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-31 13:33:28 +01:00 
			
		
		
		
	UI bugfixes on add app page (#1866)
This commit is contained in:
		| @@ -30,6 +30,7 @@ class AddAppPageState extends State<AddAppPage> { | |||||||
|   String userInput = ''; |   String userInput = ''; | ||||||
|   String searchQuery = ''; |   String searchQuery = ''; | ||||||
|   String? pickedSourceOverride; |   String? pickedSourceOverride; | ||||||
|  |   String? previousPickedSourceOverride; | ||||||
|   AppSource? pickedSource; |   AppSource? pickedSource; | ||||||
|   Map<String, dynamic> additionalSettings = {}; |   Map<String, dynamic> additionalSettings = {}; | ||||||
|   bool additionalSettingsValid = true; |   bool additionalSettingsValid = true; | ||||||
| @@ -58,6 +59,9 @@ class AddAppPageState extends State<AddAppPage> { | |||||||
|         if (overrideSource != null) { |         if (overrideSource != null) { | ||||||
|           pickedSourceOverride = overrideSource; |           pickedSourceOverride = overrideSource; | ||||||
|         } |         } | ||||||
|  |         bool overrideChanged = | ||||||
|  |             pickedSourceOverride != previousPickedSourceOverride; | ||||||
|  |         previousPickedSourceOverride = pickedSourceOverride; | ||||||
|         if (updateUrlInput) { |         if (updateUrlInput) { | ||||||
|           urlInputKey++; |           urlInputKey++; | ||||||
|         } |         } | ||||||
| @@ -69,6 +73,7 @@ class AddAppPageState extends State<AddAppPage> { | |||||||
|                 overrideSource: pickedSourceOverride) |                 overrideSource: pickedSourceOverride) | ||||||
|             : null; |             : null; | ||||||
|         if (pickedSource.runtimeType != source.runtimeType || |         if (pickedSource.runtimeType != source.runtimeType || | ||||||
|  |             overrideChanged || | ||||||
|             (prevHost != null && prevHost != source?.hosts[0])) { |             (prevHost != null && prevHost != source?.hosts[0])) { | ||||||
|           pickedSource = source; |           pickedSource = source; | ||||||
|           pickedSource?.runOnAddAppInputChange(userInput); |           pickedSource?.runOnAddAppInputChange(userInput); | ||||||
| @@ -487,7 +492,8 @@ class AddAppPageState extends State<AddAppPage> { | |||||||
|               height: 16, |               height: 16, | ||||||
|             ), |             ), | ||||||
|             GeneratedForm( |             GeneratedForm( | ||||||
|                 key: Key(pickedSource.runtimeType.toString()), |                 key: Key( | ||||||
|  |                     '${pickedSource.runtimeType.toString()}-${pickedSource?.hostChanged.toString()}-${pickedSource?.hostIdenticalDespiteAnyChange.toString()}'), | ||||||
|                 items: [ |                 items: [ | ||||||
|                   ...pickedSource!.combinedAppSpecificSettingFormItems, |                   ...pickedSource!.combinedAppSpecificSettingFormItems, | ||||||
|                   ...(pickedSourceOverride != null |                   ...(pickedSourceOverride != null | ||||||
|   | |||||||
| @@ -414,6 +414,7 @@ HttpClient createHttpClient(bool insecure) { | |||||||
| abstract class AppSource { | abstract class AppSource { | ||||||
|   List<String> hosts = []; |   List<String> hosts = []; | ||||||
|   bool hostChanged = false; |   bool hostChanged = false; | ||||||
|  |   bool hostIdenticalDespiteAnyChange = false; | ||||||
|   late String name; |   late String name; | ||||||
|   bool enforceTrackOnly = false; |   bool enforceTrackOnly = false; | ||||||
|   bool changeLogIfAnyIsMarkDown = true; |   bool changeLogIfAnyIsMarkDown = true; | ||||||
| @@ -628,9 +629,10 @@ abstract class AppSource { | |||||||
|       SettingsProvider settingsProvider) async { |       SettingsProvider settingsProvider) async { | ||||||
|     Map<String, String> results = {}; |     Map<String, String> results = {}; | ||||||
|     for (var e in sourceConfigSettingFormItems) { |     for (var e in sourceConfigSettingFormItems) { | ||||||
|       var val = hostChanged |       var val = hostChanged && !hostIdenticalDespiteAnyChange | ||||||
|           ? additionalSettings[e.key] |           ? additionalSettings[e.key] | ||||||
|           : settingsProvider.getSettingString(e.key); |           : additionalSettings[e.key] ?? | ||||||
|  |               settingsProvider.getSettingString(e.key); | ||||||
|       if (val != null) { |       if (val != null) { | ||||||
|         results[e.key] = val; |         results[e.key] = val; | ||||||
|       } |       } | ||||||
| @@ -813,9 +815,14 @@ class SourceProvider { | |||||||
|         throw UnsupportedURLError(); |         throw UnsupportedURLError(); | ||||||
|       } |       } | ||||||
|       var res = srcs.first; |       var res = srcs.first; | ||||||
|       res.hosts = [Uri.parse(url).host]; |       var originalHosts = res.hosts; | ||||||
|  |       var newHost = Uri.parse(url).host; | ||||||
|  |       res.hosts = [newHost]; | ||||||
|       res.hostChanged = true; |       res.hostChanged = true; | ||||||
|       return srcs.first; |       if (originalHosts.contains(newHost)) { | ||||||
|  |         res.hostIdenticalDespiteAnyChange = true; | ||||||
|  |       } | ||||||
|  |       return res; | ||||||
|     } |     } | ||||||
|     AppSource? source; |     AppSource? source; | ||||||
|     for (var s in sources.where((element) => element.hosts.isNotEmpty)) { |     for (var s in sources.where((element) => element.hosts.isNotEmpty)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user