Skip to content

Commit

Permalink
add an option show red button in home screen trazyn#34
Browse files Browse the repository at this point in the history
  • Loading branch information
trazyn committed Sep 22, 2017
1 parent 6fc61c5 commit 673bb57
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/js/pages/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ChatContent from './ChatContent';
loading: stores.session.loading,
showConversation: stores.chat.showConversation,
toggleConversation: stores.chat.toggleConversation,
showRedIcon: stores.settings.showRedIcon,
newChat: () => stores.newchat.toggle(true),
}))
@observer
Expand All @@ -32,9 +33,13 @@ export default class Home extends Component {
<SearchBar />
<Chats />

<div className={classes.addChat} onClick={() => this.props.newChat()}>
<i className="icon-ion-android-add" />
</div>
{
this.props.showRedIcon && (
<div className={classes.addChat} onClick={() => this.props.newChat()}>
<i className="icon-ion-android-add" />
</div>
)
}
</div>

<div className={classes.right}>
Expand Down
11 changes: 11 additions & 0 deletions src/js/pages/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import helper from 'utils/helper';
setBlockRecall: stores.settings.setBlockRecall,
remeberConversation: stores.settings.remeberConversation,
setRemeberConversation: stores.settings.setRemeberConversation,
showRedIcon: stores.settings.showRedIcon,
setShowRedIcon: stores.settings.setShowRedIcon,

user: stores.session.user,
logout: stores.session.logout,
Expand Down Expand Up @@ -80,6 +82,8 @@ export default class Settings extends Component {
setBlockRecall,
remeberConversation,
setRemeberConversation,
showRedIcon,
setShowRedIcon,
plugins,
user,
} = this.props;
Expand Down Expand Up @@ -142,6 +146,13 @@ export default class Settings extends Component {
</label>
</li>

<li>
<label htmlFor="showRedIcon">
<span>Show the red button</span>
<Switch id="showRedIcon" checked={showRedIcon} onChange={e => setShowRedIcon(e.target.checked)} />
</label>
</li>

<li>
<label htmlFor="confirmImagePaste">
<span>Image paste Confirmation</span>
Expand Down
14 changes: 12 additions & 2 deletions src/js/stores/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Settings {
@observable startup = false;
@observable blockRecall = false;
@observable remeberConversation = false;
@observable showRedIcon = true;
@observable downloads = '';
@observable plugins = [{
name: 'Message Backup',
Expand All @@ -28,6 +29,11 @@ class Settings {
self.save();
}

@action setShowRedIcon(showRedIcon) {
self.showRedIcon = showRedIcon;
self.save();
}

@action setRemeberConversation(remeberConversation) {
self.remeberConversation = remeberConversation;
self.save();
Expand Down Expand Up @@ -65,7 +71,7 @@ class Settings {

@action async init() {
var settings = await storage.get('settings');
var { alwaysOnTop, showOnTray, showNotification, blockRecall, remeberConversation, startup, downloads } = self;
var { alwaysOnTop, showOnTray, showNotification, blockRecall, remeberConversation, showRedIcon, startup, downloads } = self;

if (settings && Object.keys(settings).length) {
// Use !! force convert to a bool value
Expand All @@ -76,6 +82,7 @@ class Settings {
self.startup = !!settings.startup;
self.blockRecall = !!settings.blockRecall;
self.remeberConversation = !!settings.remeberConversation;
self.showRedIcon = !!settings.showRedIcon;
self.downloads = settings.downloads;
} else {
await storage.set('settings', {
Expand All @@ -86,6 +93,7 @@ class Settings {
downloads,
blockRecall,
remeberConversation,
showRedIcon,
});
}

Expand All @@ -104,7 +112,7 @@ class Settings {
}

save() {
var { alwaysOnTop, showOnTray, showNotification, confirmImagePaste, blockRecall, remeberConversation, startup, downloads } = self;
var { alwaysOnTop, showOnTray, showNotification, confirmImagePaste, blockRecall, remeberConversation, showRedIcon, startup, downloads } = self;

storage.set('settings', {
alwaysOnTop,
Expand All @@ -115,6 +123,7 @@ class Settings {
downloads,
blockRecall,
remeberConversation,
showRedIcon,
});

ipcRenderer.send('settings-apply', {
Expand All @@ -127,6 +136,7 @@ class Settings {
downloads,
blockRecall,
remeberConversation,
showRedIcon,
}
});
}
Expand Down

0 comments on commit 673bb57

Please sign in to comment.