Skip to content

Commit

Permalink
Consider also temporary shortcut's scripting sections when checking i…
Browse files Browse the repository at this point in the history
…f custom icons are unused
  • Loading branch information
Waboodoo committed Mar 28, 2022
1 parent 1217c96 commit 615a2a8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,21 @@ class GetUsedCustomIconsUseCase(
.map { it.icon }
.filterIsInstance(ShortcutIcon.CustomIcon::class.java)
.plus(
getReferencedIconNames(base)
getReferencedIconNames(base, temporaryShortcut)
.map { fileName ->
ShortcutIcon.CustomIcon(fileName)
}
)
.distinct()
.toList()

private fun getReferencedIconNames(base: BaseModel): Set<String> =
private fun getReferencedIconNames(base: BaseModel, temporaryShortcut: ShortcutModel?): Set<String> =
IconUtil.extractCustomIconNames(base.globalCode ?: "")
.plus(base.shortcuts.flatMap(::getReferencedIconNames))
.plus(
base.shortcuts
.mapIfNotNull(temporaryShortcut, List<ShortcutModel>::plus)
.flatMap(::getReferencedIconNames)
)

private fun getReferencedIconNames(shortcut: ShortcutModel): Set<String> =
IconUtil.extractCustomIconNames(shortcut.codeOnSuccess)
Expand Down

0 comments on commit 615a2a8

Please sign in to comment.