From bbbe074d927ac02b0b75fbc3c2db6f79ca35e8e3 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 8 Nov 2015 12:24:32 +0000 Subject: [PATCH] hide all the debugging behind if (debug) --- src/skins/vector/views/molecules/RoomTile.js | 8 +++---- .../vector/views/organisms/RoomSubList.js | 21 ++++++++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/skins/vector/views/molecules/RoomTile.js b/src/skins/vector/views/molecules/RoomTile.js index 538a7bd938..da38cb0fad 100644 --- a/src/skins/vector/views/molecules/RoomTile.js +++ b/src/skins/vector/views/molecules/RoomTile.js @@ -48,7 +48,7 @@ var roomTileSource = { lastYDelta: null, }; - console.log("roomTile beginDrag for " + item.room.roomId); + if (props.roomSubList.debug) console.log("roomTile beginDrag for " + item.room.roomId); // doing this 'correctly' with state causes react-dnd to break seemingly due to the state transitions props.room._dragging = true; @@ -60,7 +60,7 @@ var roomTileSource = { var item = monitor.getItem(); var dropResult = monitor.getDropResult(); - console.log("roomTile endDrag for " + item.room.roomId + " with didDrop=" + monitor.didDrop()); + if (props.roomSubList.debug) console.log("roomTile endDrag for " + item.room.roomId + " with didDrop=" + monitor.didDrop()); props.room._dragging = false; if (monitor.didDrop()) { @@ -107,7 +107,7 @@ var roomTileSource = { } else { // cancel the drop and reset our original position - console.log("cancelling drop & drag"); + if (props.roomSubList.debug) console.log("cancelling drop & drag"); props.roomSubList.moveRoomTile(item.room, item.originalIndex); if (item.targetList && item.targetList !== item.originalList) { item.targetList.removeRoomTile(item.room); @@ -132,7 +132,7 @@ var roomTileTarget = { if (item.targetList !== props.roomSubList) { // we've switched target, so remove the tile from the previous target. // n.b. the previous target might actually be the source list. - console.log("switched target sublist"); + if (props.roomSubList.debug) console.log("switched target sublist"); switchedTarget = true; item.targetList.removeRoomTile(item.room); item.targetList = props.roomSubList; diff --git a/src/skins/vector/views/organisms/RoomSubList.js b/src/skins/vector/views/organisms/RoomSubList.js index 8dcccc733a..c627e9d70b 100644 --- a/src/skins/vector/views/organisms/RoomSubList.js +++ b/src/skins/vector/views/organisms/RoomSubList.js @@ -21,13 +21,16 @@ var DropTarget = require('react-dnd').DropTarget; var sdk = require('matrix-react-sdk') var dis = require('matrix-react-sdk/lib/dispatcher'); +// turn this on for drop & drag console debugging galore +var debug = false; + var roomListTarget = { canDrop: function() { return true; }, drop: function(props, monitor, component) { - console.log("dropped on sublist") + if (debug) console.log("dropped on sublist") return { component: component }; }, @@ -35,7 +38,7 @@ var roomListTarget = { var item = monitor.getItem(); if (component.state.sortedList.length == 0 && props.editable) { - console.log("hovering on sublist " + props.label + ", isOver=" + monitor.isOver()); + if (debug) console.log("hovering on sublist " + props.label + ", isOver=" + monitor.isOver()); if (item.targetList !== component) { item.targetList.removeRoomTile(item.room); @@ -50,6 +53,8 @@ var roomListTarget = { var RoomSubList = React.createClass({ displayName: 'RoomSubList', + debug: debug, + propTypes: { list: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, label: React.PropTypes.string.isRequired, @@ -117,17 +122,17 @@ var RoomSubList = React.createClass({ }, moveRoomTile: function(room, atIndex) { - console.log("moveRoomTile: id " + room.roomId + ", atIndex " + atIndex); + if (debug) console.log("moveRoomTile: id " + room.roomId + ", atIndex " + atIndex); //console.log("moveRoomTile before: " + JSON.stringify(this.state.rooms)); var found = this.findRoomTile(room); var rooms = this.state.sortedList; if (found.room) { - console.log("removing at index " + found.index + " and adding at index " + atIndex); + if (debug) console.log("removing at index " + found.index + " and adding at index " + atIndex); rooms.splice(found.index, 1); rooms.splice(atIndex, 0, found.room); } else { - console.log("Adding at index " + atIndex); + if (debug) console.log("Adding at index " + atIndex); rooms.splice(atIndex, 0, room); } this.setState({ sortedList: rooms }); @@ -137,14 +142,14 @@ var RoomSubList = React.createClass({ // XXX: this isn't invoked via a property method but indirectly via // the roomList property method. Unsure how evil this is. removeRoomTile: function(room) { - console.log("remove room " + room.roomId); + if (debug) console.log("remove room " + room.roomId); var found = this.findRoomTile(room); var rooms = this.state.sortedList; if (found.room) { rooms.splice(found.index, 1); } else { - console.log*("Can't remove room " + room.roomId + " - can't find it"); + console.warn("Can't remove room " + room.roomId + " - can't find it"); } this.setState({ sortedList: rooms }); }, @@ -155,7 +160,7 @@ var RoomSubList = React.createClass({ // console.log("found: room: " + room.roomId + " with index " + index); } else { - console.log("didn't find room"); + if (debug) console.log("didn't find room"); room = null; } return ({