2018-04-05 04:57:29 +02:00
|
|
|
// @flow
|
2018-11-12 19:01:14 +01:00
|
|
|
import * as ACTIONS from 'constants/action_types';
|
|
|
|
|
|
|
|
/*
|
|
|
|
Toasts:
|
|
|
|
- First-in, first-out queue
|
|
|
|
- Simple messages that are shown in response to user interactions
|
|
|
|
- Never saved
|
|
|
|
- If they are the result of errors, use the isError flag when creating
|
|
|
|
- For errors that should interrupt user behavior, use Error
|
|
|
|
*/
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type ToastParams = {
|
2018-04-05 04:57:29 +02:00
|
|
|
message: string,
|
2018-11-12 19:01:14 +01:00
|
|
|
title?: string,
|
|
|
|
linkText?: string,
|
|
|
|
linkTarget?: string,
|
|
|
|
isError?: boolean,
|
|
|
|
};
|
|
|
|
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type Toast = {
|
2018-11-12 19:01:14 +01:00
|
|
|
id: string,
|
|
|
|
params: ToastParams,
|
|
|
|
};
|
|
|
|
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type DoToast = {
|
2018-11-12 19:01:14 +01:00
|
|
|
type: ACTIONS.CREATE_TOAST,
|
|
|
|
data: Toast,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2018-11-13 01:20:52 +01:00
|
|
|
Notifications:
|
|
|
|
- List of notifications based on user interactions/app notifications
|
2018-11-12 19:01:14 +01:00
|
|
|
- Always saved, but can be manually deleted
|
|
|
|
- Can happen in the background, or because of user interaction (ex: publish confirmed)
|
|
|
|
*/
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type Notification = {
|
2018-11-12 19:01:14 +01:00
|
|
|
id: string, // Unique id
|
|
|
|
dateCreated: number,
|
|
|
|
isRead: boolean, // Used to display "new" notifications that a user hasn't seen yet
|
2018-11-13 01:20:52 +01:00
|
|
|
source?: string, // The type/area an notification is from. Used for sorting (ex: publishes, transactions)
|
2018-11-12 19:01:14 +01:00
|
|
|
// We may want to use priority/isDismissed in the future to specify how urgent a notification is
|
|
|
|
// and if the user should see it immediately
|
|
|
|
// isDissmied: boolean,
|
|
|
|
// priority?: number
|
|
|
|
};
|
|
|
|
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type DoNotification = {
|
2018-11-13 01:20:52 +01:00
|
|
|
type: ACTIONS.CREATE_NOTIFICATION,
|
|
|
|
data: Notification,
|
2018-11-12 19:01:14 +01:00
|
|
|
};
|
|
|
|
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type DoEditNotification = {
|
2018-11-13 01:20:52 +01:00
|
|
|
type: ACTIONS.EDIT_NOTIFICATION,
|
2018-11-12 19:01:14 +01:00
|
|
|
data: {
|
2019-04-23 19:22:14 +02:00
|
|
|
notification: Notification,
|
2018-11-12 19:01:14 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type DoDeleteNotification = {
|
2018-11-13 01:20:52 +01:00
|
|
|
type: ACTIONS.DELETE_NOTIFICATION,
|
2018-11-12 19:01:14 +01:00
|
|
|
data: {
|
|
|
|
id: string, // The id to delete
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Errors:
|
|
|
|
- First-in, first-out queue
|
|
|
|
- Errors that should interupt user behavior
|
|
|
|
- For errors that can be shown without interrupting a user, use Toast with the isError flag
|
|
|
|
*/
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type ErrorNotification = {
|
2018-11-12 19:01:14 +01:00
|
|
|
title: string,
|
|
|
|
text: string,
|
|
|
|
};
|
|
|
|
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type DoError = {
|
2018-11-12 19:01:14 +01:00
|
|
|
type: ACTIONS.CREATE_ERROR,
|
2019-04-23 19:22:14 +02:00
|
|
|
data: ErrorNotification,
|
2018-11-12 19:01:14 +01:00
|
|
|
};
|
2018-04-05 04:57:29 +02:00
|
|
|
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type DoDismissError = {
|
2018-11-12 19:01:14 +01:00
|
|
|
type: ACTIONS.DISMISS_ERROR,
|
2018-04-05 04:57:29 +02:00
|
|
|
};
|
2018-04-19 20:55:37 +02:00
|
|
|
|
2018-11-12 19:01:14 +01:00
|
|
|
/*
|
|
|
|
NotificationState
|
|
|
|
*/
|
2019-04-23 19:22:14 +02:00
|
|
|
declare type NotificationState = {
|
2018-11-13 01:20:52 +01:00
|
|
|
notifications: Array<Notification>,
|
2019-04-23 19:22:14 +02:00
|
|
|
errors: Array<ErrorNotification>,
|
2018-11-12 19:01:14 +01:00
|
|
|
toasts: Array<Toast>,
|
2018-04-19 20:55:37 +02:00
|
|
|
};
|