Pinafore-Web-Client-Frontend/routes/_database/timelines/fetchNotification.js

19 lines
652 B
JavaScript
Raw Normal View History

import { fetchAccount } from './fetchAccount'
import { ACCOUNT_ID, STATUS_ID } from '../constants'
import { fetchStatus } from './fetchStatus'
export function fetchNotification (notificationsStore, statusesStore, accountsStore, id, callback) {
notificationsStore.get(id).onsuccess = e => {
let notification = e.target.result
callback(notification)
fetchAccount(accountsStore, notification[ACCOUNT_ID], account => {
notification.account = account
})
if (notification[STATUS_ID]) {
fetchStatus(statusesStore, accountsStore, notification[STATUS_ID], status => {
notification.status = status
})
}
}
}