Updates to add more ads and fix ad types.
This commit is contained in:
parent
ad850d2be6
commit
ad2d932842
17 changed files with 552 additions and 59 deletions
|
|
@ -165,10 +165,14 @@ class CloudSyncService {
|
|||
/// `false` return means the gate is closed (see [AdService.showGateAd])
|
||||
/// and this call returns [SyncResult.adGateBlocked] without uploading
|
||||
/// anything, having still pulled/merged whatever the remote side had.
|
||||
/// `everSyncedBefore` tells the caller whether a remote data file already
|
||||
/// existed — `false` means this is the very first sync this shared cloud
|
||||
/// folder has ever seen, which [AppState] uses to let that one upload
|
||||
/// through for free, with no ad required.
|
||||
Future<SyncResult> syncNow({
|
||||
bool keepLocalReceiptCopies = false,
|
||||
Duration staleLockAge = const Duration(minutes: 10),
|
||||
Future<bool> Function()? beforeUpload,
|
||||
Future<bool> Function({required bool everSyncedBefore})? beforeUpload,
|
||||
}) async {
|
||||
final appFolderId = _appFolderId;
|
||||
if (!provider.isSignedIn || appFolderId == null) {
|
||||
|
|
@ -197,7 +201,8 @@ class CloudSyncService {
|
|||
await _pullAndMerge(session, remoteInfo.id);
|
||||
}
|
||||
|
||||
if (beforeUpload != null && !await beforeUpload()) {
|
||||
if (beforeUpload != null &&
|
||||
!await beforeUpload(everSyncedBefore: remoteInfo != null)) {
|
||||
return SyncResult.adGateBlocked();
|
||||
}
|
||||
|
||||
|
|
@ -257,6 +262,16 @@ class CloudSyncService {
|
|||
if (remoteHasEntitlementTable) {
|
||||
await db.execute(mergeAdFreeEntitlementSql);
|
||||
}
|
||||
|
||||
// Same reasoning as ad_free_entitlement above — app_usage is newer
|
||||
// than vehicles/fuel_entries, so an older remote snapshot genuinely
|
||||
// won't have it.
|
||||
final remoteHasAppUsageTable = (await db.rawQuery(
|
||||
"SELECT 1 FROM remote_db.sqlite_master WHERE type = 'table' AND name = 'app_usage'",
|
||||
)).isNotEmpty;
|
||||
if (remoteHasAppUsageTable) {
|
||||
await db.execute(mergeAppUsageSql);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
await db.execute('DETACH DATABASE remote_db');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue