mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
hide all the debugging behind if (debug)
This commit is contained in:
parent
36da1accca
commit
bbbe074d92
@ -48,7 +48,7 @@ var roomTileSource = {
|
|||||||
lastYDelta: null,
|
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
|
// doing this 'correctly' with state causes react-dnd to break seemingly due to the state transitions
|
||||||
props.room._dragging = true;
|
props.room._dragging = true;
|
||||||
@ -60,7 +60,7 @@ var roomTileSource = {
|
|||||||
var item = monitor.getItem();
|
var item = monitor.getItem();
|
||||||
var dropResult = monitor.getDropResult();
|
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;
|
props.room._dragging = false;
|
||||||
if (monitor.didDrop()) {
|
if (monitor.didDrop()) {
|
||||||
@ -107,7 +107,7 @@ var roomTileSource = {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// cancel the drop and reset our original position
|
// 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);
|
props.roomSubList.moveRoomTile(item.room, item.originalIndex);
|
||||||
if (item.targetList && item.targetList !== item.originalList) {
|
if (item.targetList && item.targetList !== item.originalList) {
|
||||||
item.targetList.removeRoomTile(item.room);
|
item.targetList.removeRoomTile(item.room);
|
||||||
@ -132,7 +132,7 @@ var roomTileTarget = {
|
|||||||
if (item.targetList !== props.roomSubList) {
|
if (item.targetList !== props.roomSubList) {
|
||||||
// we've switched target, so remove the tile from the previous target.
|
// we've switched target, so remove the tile from the previous target.
|
||||||
// n.b. the previous target might actually be the source list.
|
// 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;
|
switchedTarget = true;
|
||||||
item.targetList.removeRoomTile(item.room);
|
item.targetList.removeRoomTile(item.room);
|
||||||
item.targetList = props.roomSubList;
|
item.targetList = props.roomSubList;
|
||||||
|
@ -21,13 +21,16 @@ var DropTarget = require('react-dnd').DropTarget;
|
|||||||
var sdk = require('matrix-react-sdk')
|
var sdk = require('matrix-react-sdk')
|
||||||
var dis = require('matrix-react-sdk/lib/dispatcher');
|
var dis = require('matrix-react-sdk/lib/dispatcher');
|
||||||
|
|
||||||
|
// turn this on for drop & drag console debugging galore
|
||||||
|
var debug = false;
|
||||||
|
|
||||||
var roomListTarget = {
|
var roomListTarget = {
|
||||||
canDrop: function() {
|
canDrop: function() {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
drop: function(props, monitor, component) {
|
drop: function(props, monitor, component) {
|
||||||
console.log("dropped on sublist")
|
if (debug) console.log("dropped on sublist")
|
||||||
return { component: component };
|
return { component: component };
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -35,7 +38,7 @@ var roomListTarget = {
|
|||||||
var item = monitor.getItem();
|
var item = monitor.getItem();
|
||||||
|
|
||||||
if (component.state.sortedList.length == 0 && props.editable) {
|
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) {
|
if (item.targetList !== component) {
|
||||||
item.targetList.removeRoomTile(item.room);
|
item.targetList.removeRoomTile(item.room);
|
||||||
@ -50,6 +53,8 @@ var roomListTarget = {
|
|||||||
var RoomSubList = React.createClass({
|
var RoomSubList = React.createClass({
|
||||||
displayName: 'RoomSubList',
|
displayName: 'RoomSubList',
|
||||||
|
|
||||||
|
debug: debug,
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
list: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
|
list: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
|
||||||
label: React.PropTypes.string.isRequired,
|
label: React.PropTypes.string.isRequired,
|
||||||
@ -117,17 +122,17 @@ var RoomSubList = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
moveRoomTile: function(room, atIndex) {
|
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));
|
//console.log("moveRoomTile before: " + JSON.stringify(this.state.rooms));
|
||||||
var found = this.findRoomTile(room);
|
var found = this.findRoomTile(room);
|
||||||
var rooms = this.state.sortedList;
|
var rooms = this.state.sortedList;
|
||||||
if (found.room) {
|
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(found.index, 1);
|
||||||
rooms.splice(atIndex, 0, found.room);
|
rooms.splice(atIndex, 0, found.room);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("Adding at index " + atIndex);
|
if (debug) console.log("Adding at index " + atIndex);
|
||||||
rooms.splice(atIndex, 0, room);
|
rooms.splice(atIndex, 0, room);
|
||||||
}
|
}
|
||||||
this.setState({ sortedList: rooms });
|
this.setState({ sortedList: rooms });
|
||||||
@ -137,14 +142,14 @@ var RoomSubList = React.createClass({
|
|||||||
// XXX: this isn't invoked via a property method but indirectly via
|
// XXX: this isn't invoked via a property method but indirectly via
|
||||||
// the roomList property method. Unsure how evil this is.
|
// the roomList property method. Unsure how evil this is.
|
||||||
removeRoomTile: function(room) {
|
removeRoomTile: function(room) {
|
||||||
console.log("remove room " + room.roomId);
|
if (debug) console.log("remove room " + room.roomId);
|
||||||
var found = this.findRoomTile(room);
|
var found = this.findRoomTile(room);
|
||||||
var rooms = this.state.sortedList;
|
var rooms = this.state.sortedList;
|
||||||
if (found.room) {
|
if (found.room) {
|
||||||
rooms.splice(found.index, 1);
|
rooms.splice(found.index, 1);
|
||||||
}
|
}
|
||||||
else {
|
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 });
|
this.setState({ sortedList: rooms });
|
||||||
},
|
},
|
||||||
@ -155,7 +160,7 @@ var RoomSubList = React.createClass({
|
|||||||
// console.log("found: room: " + room.roomId + " with index " + index);
|
// console.log("found: room: " + room.roomId + " with index " + index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("didn't find room");
|
if (debug) console.log("didn't find room");
|
||||||
room = null;
|
room = null;
|
||||||
}
|
}
|
||||||
return ({
|
return ({
|
||||||
|
Loading…
Reference in New Issue
Block a user