Expand Lumen stories and add island postcards
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import 'progress.dart';
|
||||
|
||||
/// An opportunity is not an impression. Only actual fullscreen displays count.
|
||||
class AdPacing {
|
||||
AdPacing(this.store, {DateTime Function()? clock})
|
||||
: now = clock ?? DateTime.now {
|
||||
started = now();
|
||||
}
|
||||
final Progress store;
|
||||
final DateTime Function() now;
|
||||
late final DateTime started;
|
||||
bool get allowed {
|
||||
final time = now();
|
||||
if (time.difference(started) < const Duration(minutes: 3)) return false;
|
||||
final last = DateTime.tryParse(store.text('ad_last_fullscreen'));
|
||||
if (last != null && time.difference(last) < const Duration(minutes: 3)) {
|
||||
return false;
|
||||
}
|
||||
final day = time.toIso8601String().substring(0, 10);
|
||||
return store.text('ad_cap_day') != day || store.number('ad_cap_count') < 6;
|
||||
}
|
||||
|
||||
void shown({required bool automatic}) {
|
||||
final time = now();
|
||||
store.set('ad_last_fullscreen', time.toIso8601String());
|
||||
if (!automatic) return;
|
||||
final day = time.toIso8601String().substring(0, 10);
|
||||
final count = store.text('ad_cap_day') == day
|
||||
? store.number('ad_cap_count')
|
||||
: 0;
|
||||
store.set('ad_cap_day', day);
|
||||
store.set('ad_cap_count', count + 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user