Skip to content

Commit ebf6d23

Browse files
lbogdanCompuIves
authored andcommitted
Reset console message count on clear. (codesandbox#318)
1 parent 37bea9e commit ebf6d23

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/app/src/app/components/sandbox/Preview/DevTools/Console/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class Console extends React.Component<Props, State> {
135135
}
136136

137137
clearConsole = () => {
138+
this.props.updateStatus('clear');
138139
this.setState({ messages: [] });
139140
};
140141

packages/app/src/app/components/sandbox/Preview/DevTools/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,14 @@ export default class DevTools extends React.PureComponent<Props, State> {
166166
return this.setState({ hidden });
167167
};
168168

169-
updateStatus = (title: string) => (status: 'warning' | 'error' | 'info') => {
169+
updateStatus = (title: string) => (
170+
status: 'warning' | 'error' | 'info' | 'clear'
171+
) => {
170172
if (!this.state.hidden) {
171173
return;
172174
}
173175

174-
const currentStatus = this.state.status[title] || {
176+
const currentStatus = (status !== 'clear' && this.state.status[title]) || {
175177
unread: 0,
176178
type: 'info',
177179
};
@@ -187,7 +189,7 @@ export default class DevTools extends React.PureComponent<Props, State> {
187189
status: {
188190
[title]: {
189191
type: newStatus,
190-
unread: currentStatus.unread + 1,
192+
unread: currentStatus.unread + (status !== 'clear' ? 1 : 0),
191193
},
192194
},
193195
});

0 commit comments

Comments
 (0)