Skip to content

Commit

Permalink
fix(settings): do not close settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ph1p committed May 1, 2020
1 parent b01fe05 commit 7769dda
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/store/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ class RootStore {
}

@action
removeAllMessages() {
removeAllMessages(cb: () => void) {
if (
(window as any).confirm('Remove all messages? (This cannot be undone)')
) {
sendMainMessage('remove-all-messages');
(window as any).alert('Messages successfully removed');
this.messages = [];
cb();
this.addNotification('Messages successfully removed');
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/views/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ const ChatView: FunctionComponent<ChatProps> = (props) => {
if (pmessage.type === 'relaunch-message') {
chatState.selectionIsChecked = true;

console.log(pmessage.payload.selection);

store.selection = pmessage.payload.selection || {};

if (store.selectionCount) {
Expand Down
9 changes: 6 additions & 3 deletions src/views/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const SettingsView: FunctionComponent<SettingsProps> = (props) => {
<input
type="text"
value={settings.name}
onBlur={() => saveSettings()}
onBlur={() => saveSettings(false)}
onChange={({ target }: any) =>
(settings.name = target.value.substr(0, 20))
}
Expand All @@ -103,7 +103,7 @@ const SettingsView: FunctionComponent<SettingsProps> = (props) => {
checked={settings.enableNotificationTooltip}
onChange={() => {
settings.enableNotificationTooltip = !settings.enableNotificationTooltip;
saveSettings();
saveSettings(false);
}}
/>
</Checkboxes>
Expand Down Expand Up @@ -137,7 +137,7 @@ const SettingsView: FunctionComponent<SettingsProps> = (props) => {
<div className="delete-history">
<button
type="submit"
onClick={store.removeAllMessages}
onClick={() => store.removeAllMessages(() => saveSettings(true))}
className="button button--secondary"
>
Delete history
Expand Down Expand Up @@ -214,6 +214,9 @@ const Settings = styled.div`
color: #fff;
padding: 5px 4px;
outline: none;
&::placeholder {
color: #fff;
}
}
.fields {
margin-bottom: 20px;
Expand Down
1 change: 1 addition & 0 deletions src/views/UserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Header from '../components/Header';
// store
import { observer } from 'mobx-react';
import { useStore } from '../store';

const UserListView: FunctionComponent = () => {
const store = useStore();

Expand Down

0 comments on commit 7769dda

Please sign in to comment.