Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear only selected connection #693

Merged
merged 2 commits into from Jun 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/reactotron-app/App/Lib/commands.js
@@ -1,4 +1,6 @@
import { action, observable } from "mobx"
import { pipe, reject } from "ramda"
import { dotPath } from "ramdasauce"

export const MAX_COMMANDS = 500

Expand Down Expand Up @@ -40,6 +42,19 @@ class Commands {
addCommand(command) {
this.buffer.push(command)
}

/**
* Clear commands for a clientId
*/
clearClientsCommands(clientId) {
const newCommands = pipe(
dotPath("all"),
reject(c => c.clientId === clientId)
)(this)

this.all.clear()
this.all.push(...newCommands)
}
}

export default Commands
8 changes: 1 addition & 7 deletions packages/reactotron-app/App/Stores/SessionStore.js
Expand Up @@ -187,13 +187,7 @@ class Session {
@action
handleCommand = command => {
if (command.type === "clear") {
const newCommands = pipe(
dotPath("commandsManager.all"),
reject(c => c.clientId === command.clientId)
)(this)

this.commandsManager.all.clear()
this.commandsManager.all.push(...newCommands)
this.commandsManager.clearClientsCommands(command.clientId)

return
} else if (command.type === "customCommand.register") {
Expand Down
6 changes: 5 additions & 1 deletion packages/reactotron-app/App/Stores/UiStore.js
Expand Up @@ -338,7 +338,11 @@ class UI {

@action
reset = () => {
this.commandsManager.all.clear()
const selectedConnection = this.getSelectedConnection()

if (!selectedConnection) return

this.commandsManager.clearClientsCommands(selectedConnection.clientId)
}

@action
Expand Down