part of "../app_property.dart";

/// Created by @Haoyi on 5/14/21

extension DefaultPropertyExtension on AppProperty {
  Future<String> getDeviceId({String? forceDeviceId}) async {
    return getOrCreateString(PropertyKeys.deviceId, forceDeviceId ?? IdUtils.uuidV4());
  }

  Future<int> getFirstInstallTime() async {
    return await AppProperty.getInstance()
        .getOrCreateInt(PropertyKeys.firstInstallTime, DateTimeUtils.currentTimeInMillis());
  }

  Future<int> getLatestLtDate() async {
    return await AppProperty.getInstance()
        .getOrCreateInt(PropertyKeys.latestLtDate, DateTimeUtils.yyyyMMddUtcNum);
  }

  Future setLatestLtDate(int dateNum) async {
    await AppProperty.getInstance().setInt(PropertyKeys.latestLtDate, dateNum);
  }

  Future<int> getLtDays() async {
    return await AppProperty.getInstance().getInt(PropertyKeys.ltDays, defValue: 0);
  }

  Future setLtDays(int days) async {
    await AppProperty.getInstance().setInt(PropertyKeys.ltDays, days);
  }

  Future<String> getLatestAnalyticsStrategy() async {
    return await AppProperty.getInstance()
        .getString(PropertyKeys.latestAnalyticsStrategy, defValue: "");
  }

  Future setLatestAnalyticsStrategy(String strategy) async {
    await AppProperty.getInstance().setString(PropertyKeys.latestAnalyticsStrategy, strategy);
  }
}
