Skip to content

Commit

Permalink
Merge branch 'main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ianz56 authored Feb 6, 2025
2 parents 1011060 + 7a53725 commit b6aa520
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
3 changes: 2 additions & 1 deletion jsHelper/expFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@
}
isFallback = false;
notice.remove();
remoteConfiguration = Spicetify?.RemoteConfigResolver?.remoteConfiguration ?? (await Spicetify.Platform?.RemoteConfigDebugAPI.getProperties());
remoteConfiguration =
Spicetify?.RemoteConfigResolver.value?.remoteConfiguration ?? (await Spicetify.Platform?.RemoteConfigDebugAPI.getProperties());
})();

for (const key of Object.keys(overrideList)) {
Expand Down
45 changes: 45 additions & 0 deletions jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,51 @@ window.Spicetify = {
Platform: {},
};

// Based on https://blog.aziz.tn/2025/01/spotify-fix-lagging-issue-on-scrolling.html
function applyScrollingFix() {
const scrollableElements = Array.from(document.querySelectorAll("*")).filter((el) => {
if (
el.id === "context-menu" ||
el.closest("#context-menu") ||
el.getAttribute("role") === "dialog" ||
el.classList.contains("popup") ||
el.getAttribute("aria-haspopup") === "true"
)
return false;

const style = window.getComputedStyle(el);
return style.overflow === "auto" || style.overflow === "scroll" || style.overflowY === "auto" || style.overflowY === "scroll";
});

for (const el of scrollableElements) {
if (!el.hasAttribute("data-scroll-optimized")) {
el.style.willChange = "transform";
el.style.transform = "translate3d(0, 0, 0)";
el.setAttribute("data-scroll-optimized", "true");
}
}
}

const observer = new MutationObserver(applyScrollingFix);

observer.observe(document.body, {
childList: true,
subtree: true,
attributes: false,
});

const originalPushState = history.pushState;
history.pushState = function (...args) {
originalPushState.apply(this, args);
setTimeout(applyScrollingFix, 100);
};

window.addEventListener("popstate", () => {
setTimeout(applyScrollingFix, 100);
});

applyScrollingFix();

(function waitForPlatform() {
if (!Spicetify._platform) {
setTimeout(waitForPlatform, 50);
Expand Down
1 change: 1 addition & 0 deletions spicetify.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func init() {
}

utils.MigrateConfigFolder()
utils.MigrateFolders()
cmd.InitConfig(quiet)

if len(commands) < 1 {
Expand Down
4 changes: 2 additions & 2 deletions src/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ func insertHomeConfig(jsPath string, flags Flag) {
return fmt.Sprintf("%sSpicetifyHomeConfig.arrange(%s)%s", submatches[1], submatches[2], submatches[3])
})

// >= 1.2.45
// >= 1.2.40
utils.ReplaceOnce(
&content,
`(&&"HomeShortsSectionData".*\],)([a-zA-Z])(\}\)\()`,
`(&&"HomeShortsSectionData".*?[\],}])([a-zA-Z])(\}\)?\()`,
func(submatches ...string) string {
return fmt.Sprintf("%sSpicetifyHomeConfig.arrange(%s)%s", submatches[1], submatches[2], submatches[3])
})
Expand Down
46 changes: 46 additions & 0 deletions src/utils/path-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,52 @@ func MigrateConfigFolder() {
}
}

func MigrateFolders() {
backupPath := filepath.Join(GetSpicetifyFolder(), "Backup")
extractedPath := filepath.Join(GetSpicetifyFolder(), "Extracted")

if _, err := os.Stat(backupPath); err == nil {
newBackupPath := GetStateFolder("Backup")
oldAbs, err := filepath.Abs(backupPath)
if err != nil {
Fatal(err)
}
newAbs, err := filepath.Abs(newBackupPath)
if err != nil {
Fatal(err)
}

if oldAbs != newAbs {
PrintBold("Migrating spicetify state (Backup, Extracted) folders")
err := Copy(backupPath, newBackupPath, true, nil)
if err != nil {
Fatal(err)
}
os.RemoveAll(backupPath)
}
}

if _, err := os.Stat(extractedPath); err == nil {
newExtractedPath := GetStateFolder("Extracted")
oldAbs, err := filepath.Abs(extractedPath)
if err != nil {
Fatal(err)
}
newAbs, err := filepath.Abs(newExtractedPath)
if err != nil {
Fatal(err)
}
if oldAbs != newAbs {
PrintBold("Migrating spicetify state (Backup, Extracted) folders")
err := Copy(extractedPath, newExtractedPath, true, nil)
if err != nil {
Fatal(err)
}
os.RemoveAll(extractedPath)
}
}
}

func ReplaceEnvVarsInString(input string) string {
var replacements []string
for _, v := range os.Environ() {
Expand Down

0 comments on commit b6aa520

Please sign in to comment.