refactor: use relativeTimeSpanString

Instead of manually formatting, use the relativeTimeSpanString function.
This commit is contained in:
KaiserBh 2023-11-14 00:30:22 +11:00
parent 67b93bb177
commit dac701bb35

View File

@ -493,11 +493,6 @@ private fun getAutomaticSyncGroup(syncPreferences: SyncPreferences): Preference.
val context = LocalContext.current val context = LocalContext.current
val syncIntervalPref = syncPreferences.syncInterval() val syncIntervalPref = syncPreferences.syncInterval()
val lastSync by syncPreferences.syncLastSync().collectAsState() val lastSync by syncPreferences.syncLastSync().collectAsState()
val formattedLastSync = DateUtils.getRelativeTimeSpanString(
lastSync.toEpochMilli(),
System.currentTimeMillis(),
DateUtils.MINUTE_IN_MILLIS,
)
return Preference.PreferenceGroup( return Preference.PreferenceGroup(
title = stringResource(R.string.pref_sync_service_category), title = stringResource(R.string.pref_sync_service_category),
@ -521,7 +516,7 @@ private fun getAutomaticSyncGroup(syncPreferences: SyncPreferences): Preference.
true true
}, },
), ),
Preference.PreferenceItem.InfoPreference(stringResource(R.string.last_synchronization, formattedLastSync)), Preference.PreferenceItem.InfoPreference(stringResource(R.string.last_synchronization, relativeTimeSpanString(lastSync.toEpochMilli()))),
), ),
) )
} }