Skip to content

Commit ce11064

Browse files
authored
Change behaviour of devtools counter (codesandbox#2653)
Before we would clear the counter of a devtool (unread count) whenever the devtools opens, also for problems and tests. It only makes sense to do this for the console though, so I moved this logic from the base devtools to the console devtools.
1 parent 7e67db3 commit ce11064

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

packages/app/src/app/components/Preview/DevTools/Console/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class ConsoleComponent extends React.Component<StyledProps> {
142142
};
143143

144144
addMessage(method, data) {
145-
if (this.props.updateStatus) {
145+
if (this.props.updateStatus && this.props.hidden) {
146146
this.props.updateStatus(this.getType(method));
147147
}
148148

@@ -190,7 +190,10 @@ class ConsoleComponent extends React.Component<StyledProps> {
190190
});
191191
};
192192

193-
componentDidUpdate() {
193+
componentDidUpdate(prevProps: StyledProps) {
194+
if (prevProps.hidden && !this.props.hidden) {
195+
this.props.updateStatus('clear');
196+
}
194197
this.scrollToBottom();
195198
}
196199

packages/app/src/app/components/Preview/DevTools/index.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,6 @@ export class DevTools extends React.PureComponent<Props, State> {
226226
status: 'success' | 'warning' | 'error' | 'info' | 'clear',
227227
count?: number
228228
) => {
229-
if (!this.state.hidden && this.getCurrentPane().id === id) {
230-
return;
231-
}
232-
233229
const currentStatus = (status !== 'clear' && this.state.status[id]) || {
234230
unread: 0,
235231
type: 'info',
@@ -402,15 +398,6 @@ export class DevTools extends React.PureComponent<Props, State> {
402398
devToolIndex: this.props.devToolIndex,
403399
tabPosition: index,
404400
});
405-
this.setState(state => ({
406-
status: {
407-
...state.status,
408-
[this.props.viewConfig.views[index].id]: {
409-
type: 'info',
410-
unread: 0,
411-
},
412-
},
413-
}));
414401
};
415402

416403
/**

0 commit comments

Comments
 (0)