forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a notification stack for error messages
- Loading branch information
Showing
17 changed files
with
115 additions
and
45 deletions.
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
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 |
---|---|---|
|
@@ -5,4 +5,4 @@ export function setAccessToken(token) { | |
type: ACCESS_TOKEN_SET, | ||
token: token | ||
}; | ||
} | ||
}; |
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,8 @@ | ||
export const NOTIFICATION_DISMISS = 'NOTIFICATION_DISMISS'; | ||
|
||
export function dismissNotification(notification) { | ||
return { | ||
type: NOTIFICATION_DISMISS, | ||
notification: notification | ||
}; | ||
}; |
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
25 changes: 25 additions & 0 deletions
25
app/assets/javascripts/components/containers/notifications_container.jsx
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,25 @@ | ||
import { connect } from 'react-redux'; | ||
import { NotificationStack } from 'react-notification'; | ||
import { dismissNotification } from '../actions/notifications'; | ||
|
||
const mapStateToProps = (state, props) => { | ||
return { | ||
notifications: state.get('notifications').map((item, i) => ({ | ||
message: item.get('message'), | ||
title: item.get('title'), | ||
key: i, | ||
action: 'Dismiss', | ||
dismissAfter: 5000 | ||
})).toJS() | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
return { | ||
onDismiss: notifiction => { | ||
dispatch(dismissNotification(notifiction)); | ||
} | ||
}; | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(NotificationStack); |
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 |
---|---|---|
|
@@ -58,4 +58,4 @@ export default function compose(state = initialState, action) { | |
default: | ||
return state; | ||
} | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -21,4 +21,4 @@ export default function compose(state = initialState, action) { | |
default: | ||
return state; | ||
} | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -10,4 +10,4 @@ export default function meta(state = initialState, action) { | |
default: | ||
return state; | ||
} | ||
} | ||
}; |
27 changes: 27 additions & 0 deletions
27
app/assets/javascripts/components/reducers/notifications.jsx
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,27 @@ | ||
import { COMPOSE_SUBMIT_FAIL, COMPOSE_UPLOAD_FAIL } from '../actions/compose'; | ||
import { FOLLOW_SUBMIT_FAIL } from '../actions/follow'; | ||
import { REBLOG_FAIL, FAVOURITE_FAIL } from '../actions/interactions'; | ||
import { TIMELINE_REFRESH_FAIL } from '../actions/timelines'; | ||
import { NOTIFICATION_DISMISS } from '../actions/notifications'; | ||
import Immutable from 'immutable'; | ||
|
||
const initialState = Immutable.List(); | ||
|
||
export default function meta(state = initialState, action) { | ||
switch(action.type) { | ||
case COMPOSE_SUBMIT_FAIL: | ||
case COMPOSE_UPLOAD_FAIL: | ||
case FOLLOW_SUBMIT_FAIL: | ||
case REBLOG_FAIL: | ||
case FAVOURITE_FAIL: | ||
case TIMELINE_REFRESH_FAIL: | ||
return state.push(Immutable.fromJS({ | ||
message: action.error.response.statusText, | ||
title: `${action.error.response.status}` | ||
})); | ||
case NOTIFICATION_DISMISS: | ||
return state.clear(); | ||
default: | ||
return state; | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -66,4 +66,4 @@ export default function timelines(state = initialState, action) { | |
default: | ||
return state; | ||
} | ||
} | ||
}; |
Oops, something went wrong.