@@ -38,31 +38,6 @@ var debug = false;
3838
3939const TRUNCATE_AT = 10 ;
4040
41- var roomListTarget = {
42- canDrop : function ( ) {
43- return true ;
44- } ,
45-
46- drop : function ( props , monitor , component ) {
47- if ( debug ) console . log ( "dropped on sublist" )
48- } ,
49-
50- hover : function ( props , monitor , component ) {
51- var item = monitor . getItem ( ) ;
52-
53- if ( component . state . sortedList . length == 0 && props . editable ) {
54- if ( debug ) console . log ( "hovering on sublist " + props . label + ", isOver=" + monitor . isOver ( ) ) ;
55-
56- if ( item . targetList !== component ) {
57- item . targetList . removeRoomTile ( item . room ) ;
58- item . targetList = component ;
59- }
60-
61- component . moveRoomTile ( item . room , 0 ) ;
62- }
63- } ,
64- } ;
65-
6641var RoomSubList = React . createClass ( {
6742 displayName : 'RoomSubList' ,
6843
@@ -279,98 +254,6 @@ var RoomSubList = React.createClass({
279254 this . setState ( this . state ) ;
280255 } ,
281256
282- moveRoomTile : function ( room , atIndex ) {
283- if ( debug ) console . log ( "moveRoomTile: id " + room . roomId + ", atIndex " + atIndex ) ;
284- //console.log("moveRoomTile before: " + JSON.stringify(this.state.rooms));
285- var found = this . findRoomTile ( room ) ;
286- var rooms = this . state . sortedList ;
287- if ( found . room ) {
288- if ( debug ) console . log ( "removing at index " + found . index + " and adding at index " + atIndex ) ;
289- rooms . splice ( found . index , 1 ) ;
290- rooms . splice ( atIndex , 0 , found . room ) ;
291- }
292- else {
293- if ( debug ) console . log ( "Adding at index " + atIndex ) ;
294- rooms . splice ( atIndex , 0 , room ) ;
295- }
296- this . setState ( { sortedList : rooms } ) ;
297- // console.log("moveRoomTile after: " + JSON.stringify(this.state.rooms));
298- } ,
299-
300- // XXX: this isn't invoked via a property method but indirectly via
301- // the roomList property method. Unsure how evil this is.
302- removeRoomTile : function ( room ) {
303- if ( debug ) console . log ( "remove room " + room . roomId ) ;
304- var found = this . findRoomTile ( room ) ;
305- var rooms = this . state . sortedList ;
306- if ( found . room ) {
307- rooms . splice ( found . index , 1 ) ;
308- }
309- else {
310- console . warn ( "Can't remove room " + room . roomId + " - can't find it" ) ;
311- }
312- this . setState ( { sortedList : rooms } ) ;
313- } ,
314-
315- findRoomTile : function ( room ) {
316- var index = this . state . sortedList . indexOf ( room ) ;
317- if ( index >= 0 ) {
318- // console.log("found: room: " + room.roomId + " with index " + index);
319- }
320- else {
321- if ( debug ) console . log ( "didn't find room" ) ;
322- room = null ;
323- }
324- return ( {
325- room : room ,
326- index : index ,
327- } ) ;
328- } ,
329-
330- calcManualOrderTagData : function ( index ) {
331- // we sort rooms by the lexicographic ordering of the 'order' metadata on their tags.
332- // for convenience, we calculate this for now a floating point number between 0.0 and 1.0.
333-
334- let orderA = 0.0 ; // by default we're next to the beginning of the list
335- if ( index > 0 ) {
336- const prevTag = this . state . sortedList [ index - 1 ] . tags [ this . props . tagName ] ;
337- if ( ! prevTag ) {
338- console . error ( "Previous room in sublist is not tagged to be in this list. This should never happen." ) ;
339- } else if ( prevTag . order === undefined ) {
340- console . error ( "Previous room in sublist has no ordering metadata. This should never happen." ) ;
341- } else {
342- orderA = prevTag . order ;
343- }
344- }
345-
346- let orderB = 1.0 ; // by default we're next to the end of the list too
347- if ( index < this . state . sortedList . length - 1 ) {
348- const nextTag = this . state . sortedList [ index + 1 ] . tags [ this . props . tagName ] ;
349- if ( ! nextTag ) {
350- console . error ( "Next room in sublist is not tagged to be in this list. This should never happen." ) ;
351- } else if ( nextTag . order === undefined ) {
352- console . error ( "Next room in sublist has no ordering metadata. This should never happen." ) ;
353- } else {
354- orderB = nextTag . order ;
355- }
356- }
357-
358- const order = ( orderA + orderB ) / 2.0 ;
359-
360- if ( order === orderA || order === orderB ) {
361- console . error ( "Cannot describe new list position. This should be incredibly unlikely." ) ;
362- this . state . sortedList . forEach ( ( room , index ) => {
363- MatrixClientPeg . get ( ) . setRoomTag (
364- room . roomId , this . props . tagName ,
365- { order : index / this . state . sortedList . length } ,
366- ) ;
367- } ) ;
368- return index / this . state . sortedList . length ;
369- }
370-
371- return order ;
372- } ,
373-
374257 makeRoomTiles : function ( ) {
375258 var self = this ;
376259 var DNDRoomTile = sdk . getComponent ( "rooms.DNDRoomTile" ) ;
0 commit comments