@@ -38,6 +38,7 @@ import xerus.monstercat.api.response.Release.Type.MCOLLECTION
3838import xerus.monstercat.api.response.Release.Type.MIX
3939import xerus.monstercat.api.response.Release.Type.PODCAST
4040import xerus.monstercat.api.response.Release.Type.SINGLE
41+ import xerus.monstercat.api.Player
4142import xerus.monstercat.cacheDir
4243import xerus.monstercat.dataDir
4344import xerus.monstercat.downloader.DownloaderSettings
@@ -105,33 +106,21 @@ class TabSettings: VTab() {
105106 val buttonWidth = 160.0
106107 addRow(
107108 createButton(" Quick Restart" ) {
108- Settings .refresh()
109- DownloaderSettings .refresh()
110- App .restart()
109+ restartApp()
111110 }.apply { prefWidth = buttonWidth },
112111 createButton(" Clear cache & Restart" ) {
113- Settings .refresh()
114- DownloaderSettings .refresh()
115- try {
116- Cache .clear()
117- App .restart()
118- } catch (e: Exception ) {
119- monsterUtilities.showError(e)
120- }
112+ Cache .clear()
113+ restartApp()
121114 }.apply { prefWidth = buttonWidth },
122115 createButton(" Reset" ) {
123116 App .stage.createAlert(Alert .AlertType .WARNING , content = " Are you sure you want to RESET ALL SETTINGS?" , buttons = * arrayOf(ButtonType .YES , ButtonType .CANCEL )).apply {
124117 initStyle(StageStyle .UTILITY )
125118 resultProperty().listen {
126119 if (it.buttonData == ButtonBar .ButtonData .YES ) {
127- try {
128- Settings .clear()
129- DownloaderSettings .clear()
130- Cache .clear()
131- } catch (e: Exception ) {
132- monsterUtilities.showError(e)
133- }
134- App .restart()
120+ Settings .clear()
121+ DownloaderSettings .clear()
122+ Cache .clear()
123+ restartApp()
135124 }
136125 }
137126 show()
@@ -143,6 +132,15 @@ class TabSettings: VTab() {
143132 )
144133 }
145134
135+ /* * Restarts the application. */
136+ private fun restartApp () {
137+ Player .fadeOut()
138+ Settings .refresh()
139+ DownloaderSettings .refresh()
140+ App .restart()
141+ Player .reset()
142+ }
143+
146144 fun feedback () {
147145 val dialog = Dialog <Feedback >().apply {
148146 (dialogPane.scene.window as Stage ).initWindowOwner(App .stage)
0 commit comments