File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -530,7 +530,7 @@ class Channel extends SnowFlake {
530
530
}
531
531
return this . parent !== undefined ;
532
532
}
533
- calculateReorder ( ) {
533
+ calculateReorder ( numbset : Set < number > ) {
534
534
let position = - 1 ;
535
535
const build : {
536
536
id : string ;
@@ -544,9 +544,15 @@ class Channel extends SnowFlake {
544
544
parent_id : string | undefined ;
545
545
} = { id : thing . id , position : undefined , parent_id : undefined } ;
546
546
547
- if ( thing . position < position ) {
547
+ if ( thing . position <= position ) {
548
548
thing . position = thisthing . position = position + 1 ;
549
549
}
550
+ while ( numbset . has ( thing . position ) ) {
551
+ thing . position ++ ;
552
+ thisthing . position = thing . position ;
553
+ console . log ( thing . position - 1 ) ;
554
+ }
555
+ numbset . add ( thing . position ) ;
550
556
position = thing . position ;
551
557
if ( thing . move_id && thing . move_id !== thing . parent_id ) {
552
558
thing . parent_id = thing . move_id ;
Original file line number Diff line number Diff line change @@ -1163,6 +1163,7 @@ class Guild extends SnowFlake {
1163
1163
position : number | undefined ;
1164
1164
parent_id : string | undefined | null ;
1165
1165
} [ ] = [ ] ;
1166
+ const numbset = new Set < number > ( ) ;
1166
1167
for ( const thing of this . headchannels ) {
1167
1168
const thisthing : {
1168
1169
id : string ;
@@ -1172,6 +1173,12 @@ class Guild extends SnowFlake {
1172
1173
if ( thing . position <= position ) {
1173
1174
thing . position = thisthing . position = position + 1 ;
1174
1175
}
1176
+ while ( numbset . has ( thing . position ) ) {
1177
+ thing . position ++ ;
1178
+ thisthing . position = thing . position ;
1179
+ console . log ( thing . position - 1 ) ;
1180
+ }
1181
+ numbset . add ( thing . position ) ;
1175
1182
position = thing . position ;
1176
1183
console . log ( position ) ;
1177
1184
if ( thing . move_id && thing . move_id !== thing . parent_id ) {
@@ -1183,7 +1190,7 @@ class Guild extends SnowFlake {
1183
1190
build . push ( thisthing ) ;
1184
1191
}
1185
1192
if ( thing . children . length > 0 ) {
1186
- const things = thing . calculateReorder ( ) ;
1193
+ const things = thing . calculateReorder ( numbset ) ;
1187
1194
for ( const thing of things ) {
1188
1195
build . push ( thing ) ;
1189
1196
}
You can’t perform that action at this time.
0 commit comments