mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Updates
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
import { store } from '@root/store'
|
||||
import * as Linking from 'expo-linking'
|
||||
import * as WebBrowser from 'expo-web-browser'
|
||||
import { getSettingsBrowser } from './slices/settingsSlice'
|
||||
|
||||
const openLink = async (url: string) => {
|
||||
switch (getSettingsBrowser(store.getState())) {
|
||||
case 'internal':
|
||||
await WebBrowser.openBrowserAsync(url)
|
||||
break
|
||||
case 'external':
|
||||
await Linking.openURL(url)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
export default openLink
|
@ -1,29 +0,0 @@
|
||||
import { store } from '@root/store'
|
||||
|
||||
const relativeTime = (date: string) => {
|
||||
const units = {
|
||||
year: 24 * 60 * 60 * 1000 * 365,
|
||||
month: (24 * 60 * 60 * 1000 * 365) / 12,
|
||||
day: 24 * 60 * 60 * 1000,
|
||||
hour: 60 * 60 * 1000,
|
||||
minute: 60 * 1000,
|
||||
second: 1000
|
||||
}
|
||||
|
||||
const rtf = new Intl.RelativeTimeFormat(store.getState().settings.language, {
|
||||
numeric: 'auto'
|
||||
})
|
||||
|
||||
const elapsed = +new Date(date) - +new Date()
|
||||
|
||||
// "Math.abs" accounts for both "past" & "future" scenarios
|
||||
for (const u in units) {
|
||||
// @ts-ignore
|
||||
if (Math.abs(elapsed) > units[u] || u == 'second') {
|
||||
// @ts-ignore
|
||||
return rtf.format(Math.round(elapsed / units[u]), u)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default relativeTime
|
Reference in New Issue
Block a user