-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #863 from alexstotsky/show-last-sync-time
(feature) Last sync time representation
- Loading branch information
Showing
12 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { useMemo } from 'react' | ||
import { useSelector } from 'react-redux' | ||
import { useTranslation } from 'react-i18next' | ||
import _floor from 'lodash/floor' | ||
import { isNil } from '@bitfinex/lib-js-util-base' | ||
|
||
import { getIsSyncing, getLastSyncTime } from 'state/sync/selectors' | ||
|
||
const getLastSyncLabel = (lastSyncTime, t) => { | ||
if (isNil(lastSyncTime)) return '' | ||
const now = Date.now() | ||
const hours = _floor((now - lastSyncTime) / 3600000) | ||
return hours > 1 | ||
? t('sync.last-sync-time.sync-was', { hours }) | ||
: t('sync.last-sync-time.sync-was-less-than-hour') | ||
} | ||
|
||
const LastSyncTime = () => { | ||
const { t } = useTranslation() | ||
const isSyncing = useSelector(getIsSyncing) | ||
const lastSyncTime = useSelector(getLastSyncTime) | ||
|
||
const lastSyncLabel = useMemo( | ||
() => getLastSyncLabel(lastSyncTime, t), | ||
[lastSyncTime, t], | ||
) | ||
|
||
const content = isSyncing | ||
? t('sync.last-sync-time.syncing') | ||
: lastSyncLabel | ||
|
||
return ( | ||
<div className='last-sync-time'> | ||
<span>{content}</span> | ||
</div> | ||
) | ||
} | ||
|
||
export default LastSyncTime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.last-sync-time { | ||
display: flex; | ||
align-items: center; | ||
margin-right: 20px; | ||
color: var(--color2); | ||
} | ||
|
||
@media screen and (max-width: 580px) { | ||
.last-sync-time { | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './LastSyncTime' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters