Skip to content

Feat/read ads setttings from flowline - #244

Merged
goku-kamehameha merged 3 commits into
devfrom
feat/read-ads-setttings-from-flowline
Aug 21, 2026
Merged

Feat/read ads setttings from flowline#244
goku-kamehameha merged 3 commits into
devfrom
feat/read-ads-setttings-from-flowline

Conversation

@JuliusCaesarCrypto

Copy link
Copy Markdown
Contributor

Change Description

Briefly describe what this PR does and why. Keep it short and clear.


Related Platforms

Which platforms are affected by your changes? Check only the ones you actually tested.

  • Android
  • iOS
  • iPad
  • Windows
  • Linux
  • Android TV
  • OpenWrt

Verification Checklist

Make sure the things you checked actually work. It's okay if you didn't test everything.

  • Project builds successfully
  • App runs without crashes on tested platforms
  • VPN connection works correctly
  • No obvious regressions observed
  • Documentation updated (if needed)

Optional (for bigger changes)

  • Added or updated unit / E2E tests
  • Checked security and edge cases

Related Links

Closes #ID.

@JuliusCaesarCrypto JuliusCaesarCrypto self-assigned this Aug 21, 2026
Copilot AI lite review requested due to automatic review settings August 21, 2026 17:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces Flowline-provided ad settings storage/reading so the app can disable AdMob dynamically (e.g., “general” or per-timezone), and updates app/package versions accordingly.

Changes:

  • Bump app and MSIX versions.
  • Persist Flowline settings into secure storage and expose them via a new getFlowlineSettings() API.
  • Update ad-environment/ad-selection logic to use Flowline settings + timezone instead of the previous Iran-only heuristic.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pubspec.yaml Version bump for the app release.
lib/core/data/local/secure_storage/secure_storage_const.dart Adds a secure-storage key for Flowline settings.
lib/core/data/local/remote/api/flowline_settings.dart New model representing Flowline ad-related settings.
lib/core/data/local/remote/api/flowline_service.dart Writes Flowline settings to storage; adds getFlowlineSettings().
lib/core/data/local/remote/api/flowline_service_interface.dart Extends service interface to return FlowlineSettings.
lib/app/app.dart Adjusts ad-init debug logging to use renamed environment fields.
lib/app/advertise_director.dart Ad strategy selection now uses Flowline settings + timezone.
lib/app/ad_director_provider.dart Renames environment flag and uses it to decide AdMob initialization.
ios/Podfile.lock Updates iOS Firebase-related pods and CocoaPods lock metadata.
Suppressed comments (2)

lib/core/data/local/remote/api/flowline_service.dart:126

  • json.decode(settingsString ?? "") will throw a FormatException when the key is missing/empty, which can break app startup. Since the value is stored via writeMap, prefer readMap which already handles missing/invalid values gracefully.
  Future<FlowlineSettings> getFlowlineSettings() async {
    final settingsString = await _secureStorage.read(flowlineSettingsKey);
    final decodedSettings = json.decode(settingsString ?? "");
    return FlowlineSettings.fromJson(decodedSettings);

lib/app/advertise_director.dart:27

  • shouldUseInternalAds fetches Flowline settings and timezone before the desktop short-circuit, and without error handling. If settings aren't cached yet (or storage is empty/corrupt), this can throw and break environment initialization. Check desktop first and wrap settings/timezone reads in a try/catch with a safe default.
    final flowlineSettings = await ref
        .read(flowlineServiceProvider)
        .getFlowlineSettings();


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 89 to +92
final advertiseStorageMap = {'api_advertise': decoded['advertise']};
final settingsStorageMap = decoded['settings'];
await _secureStorage.writeMap(apiAvertiseKey, advertiseStorageMap);
await _secureStorage.writeMap(flowlineSettingsKey, settingsStorageMap);
Comment on lines +1 to +12
class FlowlineSettings {
List<String> disabledAdmob;

FlowlineSettings({required this.disabledAdmob});

factory FlowlineSettings.fromJson(Map<String, dynamic> json) {
List<String> disabledAdmob = List<String>.from(json["disabledAdmob"]);
disabledAdmob = disabledAdmob.map((v) => v.toLowerCase()).toList();

return FlowlineSettings(disabledAdmob: disabledAdmob);
}
}
import 'package:defyx_vpn/core/data/local/remote/api/flowline_service.dart';
import 'package:defyx_vpn/core/data/local/secure_storage/secure_storage.dart';
import 'package:defyx_vpn/core/data/local/secure_storage/secure_storage_const.dart';
import 'package:defyx_vpn/modules/core/log.dart';
Comment on lines 28 to 30
String toString() =>
'AdEnvironment(isIranian: $isIranian, isMobile: $isMobilePlatform, initAdMob: $shouldInitializeAdMob)';
'AdEnvironment(isIranian: $adMobIsDisabled, isMobile: $isMobilePlatform, initAdMob: $shouldInitializeAdMob)';
}
Comment thread lib/app/app.dart
Comment on lines 47 to 49
debugPrint(
'📱 Using internal ads only (${environment.isIranian ? "Iranian user" : "desktop platform"})',
'📱 Using internal ads only (${environment.adMobIsDisabled ? "Iranian user" : "desktop platform"})',
);
@goku-kamehameha
goku-kamehameha merged commit 5041ccc into dev Aug 21, 2026
1 check passed
@goku-kamehameha
goku-kamehameha deleted the feat/read-ads-setttings-from-flowline branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants