Skip to content

Commit

Permalink
fix(home-config): support up to 1.2.45 (#3161)
Browse files Browse the repository at this point in the history
Co-authored-by: em <dev@ririxi.dev>
  • Loading branch information
ohitstom and rxri authored Sep 8, 2024
1 parent 0bbbec5 commit 2acdc4a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions css-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@
"liYe8rZ0FEQBy8j8XGJH": "main-heroCard-isPlaying",
"pgwIORyBdf4nbb4G5_Jx": "main-heroCard-PlayButtonContainer",
"I3EivnXTjYMpSbPUiYEg": "main-home-content",
"ZLSAuA1tn0bSdQRwhhj6": "main-home-content",
"Le0q6vXGEvilJEjOqgF9": "main-home-content",
"zbU90jX5VWUhVlpUda7B": "main-home-filterChipsContainer",
"cj6vRk3nFAi80HSVqX91": "main-home-filterChipsContainer",
"rX_OmqCngvY5ZCoYBZgb": "main-home-filterChipsSection",
Expand Down
12 changes: 7 additions & 5 deletions jsHelper/homeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ SpicetifyHomeConfig = {};
const stickSections = [];
const lowSections = [];
for (const uri of stickList) {
const index = sections.findIndex((a) => a?.uri === uri);
const index = sections.findIndex((a) => a?.uri === uri || a?.item.uri === uri);
if (index !== -1) {
const item = sections[index];
statusDic[item.uri] = STICKY;
const uri = item.item.uri || item.uri;
statusDic[uri] = STICKY;
stickSections.push(item);
sections[index] = undefined;
}
}
for (const uri of lowList) {
const index = sections.findIndex((a) => a?.uri === uri);
const index = sections.findIndex((a) => a?.uri === uri || a?.item.uri === uri);
if (index !== -1) {
const item = sections[index];
statusDic[item.uri] = LOWERED;
const uri = item.item.uri || item.uri;
statusDic[uri] = LOWERED;
lowSections.push(item);
sections[index] = undefined;
}
Expand Down Expand Up @@ -90,7 +92,7 @@ SpicetifyHomeConfig = {};
const main = document.querySelector(".main-home-content");
elem = [...main.querySelectorAll("section")];
for (const [index, item] of elem.entries()) {
item.dataset.uri = list[index].uri;
item.dataset.uri = list[index].uri ?? list[index].item.uri;
}

function appendItems() {
Expand Down
9 changes: 9 additions & 0 deletions src/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func AdditionalOptions(appsFolderPath string, flags Flag) {
filepath.Join(appsFolderPath, "xpui", "xpui.js"): insertCustomApp,
filepath.Join(appsFolderPath, "xpui", "xpui.js"): insertExpFeatures,
filepath.Join(appsFolderPath, "xpui", "xpui.js"): insertSidebarConfig,
filepath.Join(appsFolderPath, "xpui", "xpui.js"): insertHomeConfig,
filepath.Join(appsFolderPath, "xpui", "vendor~xpui.js"): insertExpFeatures,
filepath.Join(appsFolderPath, "xpui", "home-v2.js"): insertHomeConfig,
filepath.Join(appsFolderPath, "xpui", "xpui-desktop-modals.js"): insertVersionInfo,
Expand Down Expand Up @@ -340,6 +341,14 @@ func insertHomeConfig(jsPath string, flags Flag) {
return fmt.Sprintf("%sSpicetifyHomeConfig.arrange(%s)%s", submatches[1], submatches[2], submatches[3])
})

// >= 1.2.45
utils.ReplaceOnce(
&content,
`(&&"HomeShortsSectionData".*\],)([a-zA-Z])(\}\)\()`,
func(submatches ...string) string {
return fmt.Sprintf("%sSpicetifyHomeConfig.arrange(%s)%s", submatches[1], submatches[2], submatches[3])
})

return content
})
}
Expand Down

0 comments on commit 2acdc4a

Please sign in to comment.