Skip to content

Commit

Permalink
feat: 🎸 Notifications use modified, then created date
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanObrink committed Oct 1, 2021
1 parent 7898336 commit a655bbc
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
17 changes: 15 additions & 2 deletions packages/app/components/__tests__/Notification.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) => {
Expand All @@ -22,16 +23,28 @@ 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()
})

test('renders subtitle without date', () => {
const itemWithoutDate = {
...defaultItem,
dateCreated: undefined,
dateModified: undefined,
}

const screen = setup({ item: itemWithoutDate })
Expand All @@ -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()
})
7 changes: 5 additions & 2 deletions packages/app/components/childListItem.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
7 changes: 2 additions & 5 deletions packages/app/components/notification.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
Expand Down
8 changes: 0 additions & 8 deletions packages/app/components/notificationsList.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions packages/app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a655bbc

Please sign in to comment.