feat: 🎸 Notifications use modified, then created date
This commit is contained in:
parent
789833625a
commit
a655bbc590
|
@ -7,6 +7,7 @@ const defaultItem = {
|
|||
sender: 'Planering',
|
||||
category: 'Bedömning',
|
||||
dateCreated: '2021-02-15T09:13:28.484Z',
|
||||
dateModified: '2021-02-15T09:14:28.484Z',
|
||||
}
|
||||
|
||||
const setup = (customProps = {}) => {
|
||||
|
@ -22,9 +23,20 @@ beforeEach(() => {
|
|||
MockDate.set('2021-02-15T09:30:28.484Z')
|
||||
})
|
||||
|
||||
test('renders subtitle with date', () => {
|
||||
test('renders subtitle with modified date', () => {
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Bedömning • för 16 minuter sedan')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders subtitle with created date', () => {
|
||||
const itemWithoutModifiedDate = {
|
||||
...defaultItem,
|
||||
dateModified: undefined,
|
||||
}
|
||||
|
||||
const screen = setup({ item: itemWithoutModifiedDate })
|
||||
|
||||
expect(screen.getByText('Bedömning • för 17 minuter sedan')).toBeTruthy()
|
||||
})
|
||||
|
||||
|
@ -32,6 +44,7 @@ test('renders subtitle without date', () => {
|
|||
const itemWithoutDate = {
|
||||
...defaultItem,
|
||||
dateCreated: undefined,
|
||||
dateModified: undefined,
|
||||
}
|
||||
|
||||
const screen = setup({ item: itemWithoutDate })
|
||||
|
@ -47,5 +60,5 @@ test('renders subtitle without category', () => {
|
|||
|
||||
const screen = setup({ item: itemWithoutCategory })
|
||||
|
||||
expect(screen.getByText('för 17 minuter sedan')).toBeTruthy()
|
||||
expect(screen.getByText('för 16 minuter sedan')).toBeTruthy()
|
||||
})
|
||||
|
|
|
@ -53,8 +53,11 @@ export const ChildListItem = ({ child, color }: ChildListItemProps) => {
|
|||
moment().add(7, 'days').toISOString()
|
||||
)
|
||||
|
||||
const notificationsThisWeek = notifications.filter(({ dateCreated }) =>
|
||||
dateCreated ? moment(dateCreated).isSame(moment(), 'week') : false
|
||||
const notificationsThisWeek = notifications.filter(
|
||||
({ dateCreated, dateModified }) => {
|
||||
const date = dateModified || dateCreated
|
||||
return date ? moment(date).isSame(moment(), 'week') : false
|
||||
}
|
||||
)
|
||||
|
||||
const newsThisWeek = news.filter(({ modified, published }) => {
|
||||
|
|
|
@ -16,11 +16,8 @@ export const Notification = ({ item }: NotificationProps) => {
|
|||
const open = () => setIsOpen(true)
|
||||
const close = () => setIsOpen(false)
|
||||
|
||||
const displayDate = item.dateModified
|
||||
? moment(item.dateModified).fromNow()
|
||||
: item.dateCreated
|
||||
? moment(item.dateCreated).fromNow()
|
||||
: null
|
||||
const date = item.dateModified || item.dateCreated
|
||||
const displayDate = date ? moment(date).fromNow() : null
|
||||
|
||||
const sharedCookiesEnabled: boolean = Boolean(
|
||||
item.url && item.url.startsWith('https://start.unikum.net/')
|
||||
|
|
|
@ -10,14 +10,6 @@ export const NotificationsList = () => {
|
|||
const child = useChild()
|
||||
const { data } = useNotifications(child)
|
||||
|
||||
data.sort((a, b) =>
|
||||
a.dateModified > b.dateModified
|
||||
? -1
|
||||
: b.dateModified > a.dateModified
|
||||
? 1
|
||||
: 0
|
||||
)
|
||||
|
||||
return (
|
||||
<List
|
||||
style={styles.container}
|
||||
|
|
|
@ -606,7 +606,7 @@ EXTERNAL SOURCES:
|
|||
SPEC CHECKSUMS:
|
||||
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
|
||||
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
|
||||
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
|
||||
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
|
||||
FBLazyVector: 33c82491102f20ecddb6c6a2c273696ace3191e0
|
||||
FBReactNativeSpec: df8f81d2a7541ee6755a047b398a5cb5a72acd0e
|
||||
Flipper: b1fddf9a17c32097b2b4c806ad158b2f36bb2692
|
||||
|
@ -619,7 +619,7 @@ SPEC CHECKSUMS:
|
|||
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
|
||||
FlipperKit: aec2d931adeee48a07bab1ea8bcc8a6bb87dfce4
|
||||
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
|
||||
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
|
||||
glog: 5337263514dd6f09803962437687240c5dc39aa4
|
||||
hermes-engine: 7dcd1dbd908e6353bd7e4a4add72dba7bf76bf84
|
||||
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
|
||||
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"@react-navigation/stack": "5.14.4",
|
||||
"@skolplattformen/api-hooks": "3.0.0",
|
||||
"@skolplattformen/curriculum": "1.4.2",
|
||||
"@skolplattformen/embedded-api": "5.3.3",
|
||||
"@skolplattformen/embedded-api": "5.4.0",
|
||||
"@ui-kitten/components": "5.0.0",
|
||||
"@ui-kitten/eva-icons": "5.0.0",
|
||||
"buffer": "6.0.3",
|
||||
|
|
|
@ -1341,10 +1341,10 @@
|
|||
dependencies:
|
||||
deepmerge "^4.2.2"
|
||||
|
||||
"@skolplattformen/embedded-api@5.3.3":
|
||||
version "5.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@skolplattformen/embedded-api/-/embedded-api-5.3.3.tgz#9c8b9c93a4d3f4857c79568a6be8b6bcab1817c2"
|
||||
integrity sha512-rLE23xHdXSeBnax/pWEaVMG2nB9iHAk6tpIOnjCzcFUbm4OYNeJlfgoJkIZgNsDu5wYGJad7VJU0L0FSwVVnMA==
|
||||
"@skolplattformen/embedded-api@5.4.0":
|
||||
version "5.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@skolplattformen/embedded-api/-/embedded-api-5.4.0.tgz#3346190d4f5251716fce77f39276c86a9fe3ba94"
|
||||
integrity sha512-N1kkvm9R2W+la7Ipkl5zomp23Rf7Xx1lgyLy7mIHN0kI6p474Tk+shDwe4GNrcFGlxMCm/ouds1PXNMrQYj3Zg==
|
||||
dependencies:
|
||||
camelcase-keys "^6.2.2"
|
||||
change-case "^4.1.2"
|
||||
|
|
Loading…
Reference in New Issue