simplified time zone offset check
This commit is contained in:
parent
66f0e2b1e9
commit
ec7e4ac2f2
7 changed files with 12 additions and 34 deletions
|
@ -33,7 +33,6 @@ class DeviceHandler(private val context: Context) : MethodCallHandler {
|
||||||
when (call.method) {
|
when (call.method) {
|
||||||
"canManageMedia" -> safe(call, result, ::canManageMedia)
|
"canManageMedia" -> safe(call, result, ::canManageMedia)
|
||||||
"getCapabilities" -> defaultScope.launch { safe(call, result, ::getCapabilities) }
|
"getCapabilities" -> defaultScope.launch { safe(call, result, ::getCapabilities) }
|
||||||
"getDefaultTimeZoneRawOffsetMillis" -> safe(call, result, ::getDefaultTimeZoneRawOffsetMillis)
|
|
||||||
"getLocales" -> safe(call, result, ::getLocales)
|
"getLocales" -> safe(call, result, ::getLocales)
|
||||||
"setLocaleConfig" -> safe(call, result, ::setLocaleConfig)
|
"setLocaleConfig" -> safe(call, result, ::setLocaleConfig)
|
||||||
"getPerformanceClass" -> safe(call, result, ::getPerformanceClass)
|
"getPerformanceClass" -> safe(call, result, ::getPerformanceClass)
|
||||||
|
@ -67,10 +66,6 @@ class DeviceHandler(private val context: Context) : MethodCallHandler {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDefaultTimeZoneRawOffsetMillis(@Suppress("unused_parameter") call: MethodCall, result: MethodChannel.Result) {
|
|
||||||
result.success(TimeZone.getDefault().rawOffset)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getLocales(@Suppress("unused_parameter") call: MethodCall, result: MethodChannel.Result) {
|
private fun getLocales(@Suppress("unused_parameter") call: MethodCall, result: MethodChannel.Result) {
|
||||||
fun toMap(locale: Locale): FieldMap = hashMapOf(
|
fun toMap(locale: Locale): FieldMap = hashMapOf(
|
||||||
"language" to locale.language,
|
"language" to locale.language,
|
||||||
|
|
|
@ -87,9 +87,9 @@ mixin AppSettings on SettingsAccess {
|
||||||
|
|
||||||
set forceWesternArabicNumerals(bool newValue) => set(SettingKeys.forceWesternArabicNumeralsKey, newValue);
|
set forceWesternArabicNumerals(bool newValue) => set(SettingKeys.forceWesternArabicNumeralsKey, newValue);
|
||||||
|
|
||||||
int get catalogTimeZoneRawOffsetMillis => getInt(SettingKeys.catalogTimeZoneRawOffsetMillisKey) ?? 0;
|
int get catalogTimeZoneOffsetMillis => getInt(SettingKeys.catalogTimeZoneOffsetMillisKey) ?? 0;
|
||||||
|
|
||||||
set catalogTimeZoneRawOffsetMillis(int newValue) => set(SettingKeys.catalogTimeZoneRawOffsetMillisKey, newValue);
|
set catalogTimeZoneOffsetMillis(int newValue) => set(SettingKeys.catalogTimeZoneOffsetMillisKey, newValue);
|
||||||
|
|
||||||
double getTileExtent(String routeName) => getDouble(SettingKeys.tileExtentPrefixKey + routeName) ?? 0;
|
double getTileExtent(String routeName) => getDouble(SettingKeys.tileExtentPrefixKey + routeName) ?? 0;
|
||||||
|
|
||||||
|
|
|
@ -59,15 +59,13 @@ class MediaStoreSource extends CollectionSource {
|
||||||
await vaults.init();
|
await vaults.init();
|
||||||
await favourites.init();
|
await favourites.init();
|
||||||
await covers.init();
|
await covers.init();
|
||||||
final currentTimeZoneOffset = await deviceService.getDefaultTimeZoneRawOffsetMillis();
|
final currentTimeZoneOffset = DateTime.now().timeZoneOffset.inMilliseconds;
|
||||||
if (currentTimeZoneOffset != null) {
|
final catalogTimeZoneOffset = settings.catalogTimeZoneOffsetMillis;
|
||||||
final catalogTimeZoneOffset = settings.catalogTimeZoneRawOffsetMillis;
|
if (currentTimeZoneOffset != catalogTimeZoneOffset) {
|
||||||
if (currentTimeZoneOffset != catalogTimeZoneOffset) {
|
unawaited(reportService.recordError('Time zone offset change: $currentTimeZoneOffset -> $catalogTimeZoneOffset. Clear catalog metadata to get correct date/times.', null));
|
||||||
unawaited(reportService.recordError('Time zone offset change: $currentTimeZoneOffset -> $catalogTimeZoneOffset. Clear catalog metadata to get correct date/times.', null));
|
await localMediaDb.clearDates();
|
||||||
await localMediaDb.clearDates();
|
await localMediaDb.clearCatalogMetadata();
|
||||||
await localMediaDb.clearCatalogMetadata();
|
settings.catalogTimeZoneOffsetMillis = currentTimeZoneOffset;
|
||||||
settings.catalogTimeZoneRawOffsetMillis = currentTimeZoneOffset;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await loadDates();
|
await loadDates();
|
||||||
debugPrint('$runtimeType load essentials complete in ${stopwatch.elapsed.inMilliseconds}ms');
|
debugPrint('$runtimeType load essentials complete in ${stopwatch.elapsed.inMilliseconds}ms');
|
||||||
|
|
|
@ -8,8 +8,6 @@ abstract class DeviceService {
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getCapabilities();
|
Future<Map<String, dynamic>> getCapabilities();
|
||||||
|
|
||||||
Future<int?> getDefaultTimeZoneRawOffsetMillis();
|
|
||||||
|
|
||||||
Future<List<Locale>> getLocales();
|
Future<List<Locale>> getLocales();
|
||||||
|
|
||||||
Future<void> setLocaleConfig(List<Locale> locales);
|
Future<void> setLocaleConfig(List<Locale> locales);
|
||||||
|
@ -52,16 +50,6 @@ class PlatformDeviceService implements DeviceService {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<int?> getDefaultTimeZoneRawOffsetMillis() async {
|
|
||||||
try {
|
|
||||||
return await _platform.invokeMethod('getDefaultTimeZoneRawOffsetMillis');
|
|
||||||
} on PlatformException catch (e, stack) {
|
|
||||||
await reportService.recordError(e, stack);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<Locale>> getLocales() async {
|
Future<List<Locale>> getLocales() async {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -55,7 +55,7 @@ class _DebugSettingsSectionState extends State<DebugSettingsSection> with Automa
|
||||||
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
|
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
|
||||||
child: InfoRowGroup(
|
child: InfoRowGroup(
|
||||||
info: {
|
info: {
|
||||||
'catalogTimeZoneRawOffsetMillis': '${settings.catalogTimeZoneRawOffsetMillis}',
|
'catalogTimeZoneRawOffsetMillis': '${settings.catalogTimeZoneOffsetMillis}',
|
||||||
'tileExtent - Collection': '${settings.getTileExtent(CollectionPage.routeName)}',
|
'tileExtent - Collection': '${settings.getTileExtent(CollectionPage.routeName)}',
|
||||||
'tileExtent - Albums': '${settings.getTileExtent(AlbumListPage.routeName)}',
|
'tileExtent - Albums': '${settings.getTileExtent(AlbumListPage.routeName)}',
|
||||||
'tileExtent - Countries': '${settings.getTileExtent(CountryListPage.routeName)}',
|
'tileExtent - Countries': '${settings.getTileExtent(CountryListPage.routeName)}',
|
||||||
|
|
|
@ -3,7 +3,7 @@ class SettingKeys {
|
||||||
|
|
||||||
static const Set<String> _internalKeys = {
|
static const Set<String> _internalKeys = {
|
||||||
hasAcceptedTermsKey,
|
hasAcceptedTermsKey,
|
||||||
catalogTimeZoneRawOffsetMillisKey,
|
catalogTimeZoneOffsetMillisKey,
|
||||||
searchHistoryKey,
|
searchHistoryKey,
|
||||||
platformAccelerometerRotationKey,
|
platformAccelerometerRotationKey,
|
||||||
platformTransitionAnimationScaleKey,
|
platformTransitionAnimationScaleKey,
|
||||||
|
@ -21,7 +21,7 @@ class SettingKeys {
|
||||||
static const isErrorReportingAllowedKey = 'is_crashlytics_enabled';
|
static const isErrorReportingAllowedKey = 'is_crashlytics_enabled';
|
||||||
static const localeKey = 'locale';
|
static const localeKey = 'locale';
|
||||||
static const forceWesternArabicNumeralsKey = 'force_western_arabic_numerals';
|
static const forceWesternArabicNumeralsKey = 'force_western_arabic_numerals';
|
||||||
static const catalogTimeZoneRawOffsetMillisKey = 'catalog_time_zone_raw_offset_millis';
|
static const catalogTimeZoneOffsetMillisKey = 'catalog_time_zone_raw_offset_millis';
|
||||||
static const tileExtentPrefixKey = 'tile_extent_';
|
static const tileExtentPrefixKey = 'tile_extent_';
|
||||||
static const tileLayoutPrefixKey = 'tile_layout_';
|
static const tileLayoutPrefixKey = 'tile_layout_';
|
||||||
static const entryRenamingPatternKey = 'entry_renaming_pattern';
|
static const entryRenamingPatternKey = 'entry_renaming_pattern';
|
||||||
|
|
|
@ -3,9 +3,6 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:test/fake.dart';
|
import 'package:test/fake.dart';
|
||||||
|
|
||||||
class FakeDeviceService extends Fake implements DeviceService {
|
class FakeDeviceService extends Fake implements DeviceService {
|
||||||
@override
|
|
||||||
Future<int> getDefaultTimeZoneRawOffsetMillis() => SynchronousFuture(3600000);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> getAvailableHeapSize() => SynchronousFuture(0x7fffffff);
|
Future<int> getAvailableHeapSize() => SynchronousFuture(0x7fffffff);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue