Skip to content

Commit

Permalink
Merge pull request #693 from infinitered/connection-based-clearing
Browse files Browse the repository at this point in the history
Clear only selected connection
  • Loading branch information
skellock committed Jun 10, 2018
2 parents 0dd58e6 + f427b33 commit 275c8bd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
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

0 comments on commit 275c8bd

Please sign in to comment.