@@ -6,6 +6,7 @@ import url from "node:url";
6
6
import { Menu , app , dialog , session } from "@electron/remote" ;
7
7
import * as remote from "@electron/remote" ;
8
8
import * as Sentry from "@sentry/electron/renderer" ;
9
+ import SortableJS from "sortablejs" ;
9
10
10
11
import type { Config } from "../../common/config-util.js" ;
11
12
import * as ConfigUtil from "../../common/config-util.js" ;
@@ -57,7 +58,7 @@ const dingSound = new Audio(
57
58
58
59
export class ServerManagerView {
59
60
$addServerButton : HTMLButtonElement ;
60
- $tabsContainer : Element ;
61
+ $tabsContainer : HTMLElement ;
61
62
$reloadButton : HTMLButtonElement ;
62
63
$loadingIndicator : HTMLButtonElement ;
63
64
$settingsButton : HTMLButtonElement ;
@@ -81,6 +82,7 @@ export class ServerManagerView {
81
82
tabIndex : number ;
82
83
presetOrgs : string [ ] ;
83
84
preferenceView ?: PreferenceView ;
85
+ sortableSidebar : SortableJS | null ;
84
86
constructor ( ) {
85
87
this . $addServerButton = document . querySelector ( "#add-tab" ) ! ;
86
88
this . $tabsContainer = document . querySelector ( "#tabs-container" ) ! ;
@@ -123,6 +125,7 @@ export class ServerManagerView {
123
125
this . presetOrgs = [ ] ;
124
126
this . functionalTabs = new Map ( ) ;
125
127
this . tabIndex = 0 ;
128
+ this . sortableSidebar = null ;
126
129
}
127
130
128
131
async init ( ) : Promise < void > {
@@ -235,6 +238,20 @@ export class ServerManagerView {
235
238
initSidebar ( ) : void {
236
239
const showSidebar = ConfigUtil . getConfigItem ( "showSidebar" , true ) ;
237
240
this . toggleSidebar ( showSidebar ) ;
241
+ this . sortableSidebar = new SortableJS ( this . $tabsContainer , {
242
+ animation : 150 ,
243
+ onEnd : ( event : SortableJS . SortableEvent ) => {
244
+ // Update the domain order in the database
245
+ DomainUtil . updateDomainOrder ( event . oldIndex ?? 0 , event . newIndex ?? 0 ) ;
246
+
247
+ // Update the current active tab index
248
+ this . activeTabIndex = event . newIndex ?? 0 ;
249
+ ConfigUtil . setConfigItem ( "lastActiveTab" , event . newIndex ?? 0 ) ;
250
+
251
+ // Reload the app to give the tabs their new indexes
252
+ ipcRenderer . send ( "reload-full-app" ) ;
253
+ } ,
254
+ } ) ;
238
255
}
239
256
240
257
// Remove the stale UA string from the disk if the app is not freshly
0 commit comments