Skip to content

Commit

Permalink
fix(apply): patch for 1.2.2 (spicetify#2078)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrie25 authored Jan 1, 2023
1 parent 6bcf292 commit d8be8ec
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func getColorCSS(scheme map[string]string) string {
func insertCustomApp(jsPath string, flags Flag) {
utils.ModifyFile(jsPath, func(content string) string {
const REACT_REGEX = `(\w+(?:\(\))?)\.lazy\(\((?:\(\)=>|function\(\)\{return )(\w+)\.(\w+)\(\d+\)\.then\(\w+\.bind\(\w+,\d+\)\)\}?\)\)`
const REACT_ELEMENT_REGEX = `(\w+(?:\(\))?\.createElement|\([\w$\.,]+\))\(([\w\.]+),\{path:"\/collection"(?:,[:.\w,{}()/*"]+)?\}`
const REACT_ELEMENT_REGEX = `(\w+(?:\(\))?\.createElement|\([\w$\.,]+\))\(([\w\.]+),\{path:"\/collection"(?:,(element|children)?[:.\w,{}()/*"]+)?\}`
reactSymbs := utils.FindSymbol(
"Custom app React symbols",
content,
Expand All @@ -231,6 +231,14 @@ func insertCustomApp(jsPath string, flags Flag) {
cssEnableMap := ""
appNameArray := ""

// Spotify's new route system
wildcard := ""
if eleSymbs[2] == "" {
eleSymbs[2] = "children"
} else if eleSymbs[2] == "element" {
wildcard = "*"
}

for index, app := range flags.CustomApp {
appName := `spicetify-routes-` + app
appMap += fmt.Sprintf(`"%s":"%s",`, appName, appName)
Expand All @@ -242,8 +250,8 @@ func insertCustomApp(jsPath string, flags Flag) {
appName, reactSymbs[1], reactSymbs[1], appName)

appEleMap += fmt.Sprintf(
`%s(%s,{path:"/%s",pathV6:"/%s/*",children:%s(spicetifyApp%d,{})}),`,
eleSymbs[0], eleSymbs[1], app, app, eleSymbs[0], index)
`%s(%s,{path:"/%s/%s",pathV6:"/%s/*",%s:%s(spicetifyApp%d,{})}),`,
eleSymbs[0], eleSymbs[1], app, wildcard, app, eleSymbs[2], eleSymbs[0], index)

cssEnableMap += fmt.Sprintf(`,"%s":1`, appName)
}
Expand Down

0 comments on commit d8be8ec

Please sign in to comment.