Skip to content

Commit

Permalink
Add adjustable delay for marking newly selected sessions as read (air…
Browse files Browse the repository at this point in the history
  • Loading branch information
maksis committed Oct 4, 2016
1 parent fc8ab73 commit 0bca456
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions src/decorators/ActiveSessionDecorator.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';
import React from 'react';

import LocalSettingStore from 'stores/LocalSettingStore';
import { LocalSettings } from 'constants/SettingConstants';

// This decorator will fire updates for currently active session
// and set them as read
Expand All @@ -11,14 +13,23 @@ export default function (Component) {
actions: React.PropTypes.object, // Required (cloned)
},

setRead(id) {
this.props.actions.setRead(id);
this.readTimeout = null;
},

setSession(id) {
const { actions } = this.props;
actions.sessionChanged(id);
if (this.readTimeout) {
clearTimeout(this.readTimeout);
this.setRead(this.props.session.id);
}

this.props.actions.sessionChanged(id);
if (!id) {
return;
}

actions.setRead(id);
this.readTimeout = setTimeout(_ => this.setRead(id), LocalSettingStore.getValue(LocalSettings.UNREAD_LABEL_DELAY) * 1000);
},

componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Settings/components/SaveButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SaveButton = React.createClass({
*/
saveHandler: React.PropTypes.func.isRequired,

local: React.PropTypes.bool.isRequired,
local: React.PropTypes.bool,
},

getInitialState() {
Expand Down
2 changes: 1 addition & 1 deletion src/stores/LocalSettingStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Settings = [
title: 'Error events',
}, {
key: LocalSettings.UNREAD_LABEL_DELAY,
defaultValue: 0,
defaultValue: 2,
title: 'Delay for marking sessions as read',
unit: 'seconds',
}
Expand Down

0 comments on commit 0bca456

Please # to comment.