Add indicator of unread content to window title when web UI is out of focus (#11560)
Fix #1288
This commit is contained in:
parent
5f63339744
commit
c09ecbc53e
7 changed files with 95 additions and 1 deletions
|
@ -32,6 +32,7 @@ import suggestions from './suggestions';
|
|||
import polls from './polls';
|
||||
import identity_proofs from './identity_proofs';
|
||||
import trends from './trends';
|
||||
import missed_updates from './missed_updates';
|
||||
|
||||
const reducers = {
|
||||
dropdown_menu,
|
||||
|
@ -67,6 +68,7 @@ const reducers = {
|
|||
suggestions,
|
||||
polls,
|
||||
trends,
|
||||
missed_updates,
|
||||
};
|
||||
|
||||
export default combineReducers(reducers);
|
||||
|
|
23
app/javascript/mastodon/reducers/missed_updates.js
Normal file
23
app/javascript/mastodon/reducers/missed_updates.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { Map as ImmutableMap } from 'immutable';
|
||||
import { NOTIFICATIONS_UPDATE } from 'mastodon/actions/notifications';
|
||||
import { TIMELINE_UPDATE } from 'mastodon/actions/timelines';
|
||||
import { APP_FOCUS, APP_UNFOCUS } from 'mastodon/actions/app';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
focused: true,
|
||||
unread: 0,
|
||||
});
|
||||
|
||||
export default function missed_updates(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case APP_FOCUS:
|
||||
return state.set('focused', true).set('unread', 0);
|
||||
case APP_UNFOCUS:
|
||||
return state.set('focused', false);
|
||||
case NOTIFICATIONS_UPDATE:
|
||||
case TIMELINE_UPDATE:
|
||||
return state.get('focused') ? state : state.update('unread', x => x + 1);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
Reference in a new issue