Skip to content

Commit 4d463d2

Browse files
committed
Export icons in Dispatchers.IO
1 parent 8b28c99 commit 4d463d2

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/mode/iconpack/conversion/IconPackConversionViewModel.kt

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import kotlinx.coroutines.flow.asStateFlow
3535
import kotlinx.coroutines.flow.launchIn
3636
import kotlinx.coroutines.flow.onEach
3737
import kotlinx.coroutines.launch
38+
import kotlinx.coroutines.withContext
3839

3940
class IconPackConversionViewModel(
4041
savedState: MutableSavedState,
@@ -197,13 +198,15 @@ class IconPackConversionViewModel(
197198
),
198199
)
199200

200-
vectorSpecOutput.content.writeToKt(
201-
outputDir = when {
202-
settings.flatPackage -> settings.iconPackDestination
203-
else -> "${settings.iconPackDestination}/${iconPack.currentNestedPack.lowercase()}"
204-
},
205-
nameWithoutExtension = vectorSpecOutput.name,
206-
)
201+
withContext(Dispatchers.IO) {
202+
vectorSpecOutput.content.writeToKt(
203+
outputDir = when {
204+
settings.flatPackage -> settings.iconPackDestination
205+
else -> "${settings.iconPackDestination}/${iconPack.currentNestedPack.lowercase()}"
206+
},
207+
nameWithoutExtension = vectorSpecOutput.name,
208+
)
209+
}
207210
}
208211
is IconPack.Single -> {
209212
val vectorSpecOutput = ImageVectorGenerator.convert(
@@ -225,10 +228,12 @@ class IconPackConversionViewModel(
225228
),
226229
)
227230

228-
vectorSpecOutput.content.writeToKt(
229-
outputDir = settings.iconPackDestination,
230-
nameWithoutExtension = vectorSpecOutput.name,
231-
)
231+
withContext(Dispatchers.IO) {
232+
vectorSpecOutput.content.writeToKt(
233+
outputDir = settings.iconPackDestination,
234+
nameWithoutExtension = vectorSpecOutput.name,
235+
)
236+
}
232237
}
233238
}
234239
}
@@ -316,8 +321,7 @@ class IconPackConversionViewModel(
316321

317322
private fun processText(text: String) = viewModelScope.launch(Dispatchers.Default) {
318323
val iconName = ""
319-
val output =
320-
runCatching { SvgXmlParser.toIrImageVector(parser = ParserType.Jvm, text, iconName) }.getOrNull()
324+
val output = runCatching { SvgXmlParser.toIrImageVector(parser = ParserType.Jvm, text, iconName) }.getOrNull()
321325

322326
val icon = when (output) {
323327
null -> BatchIcon.Broken(

0 commit comments

Comments
 (0)