SchemeDownloader: add support for spaces in names

This commit is contained in:
Ly-sec
2025-11-29 13:36:37 +01:00
parent e627e67463
commit d53a3d8de2
2 changed files with 21 additions and 6 deletions
@@ -241,9 +241,14 @@ Popup {
// Rate limit hit - try to use cache if available
downloadError = I18n.tr("settings.color-scheme.download.error.rate-limit");
Logger.w("ColorSchemeDownload", downloadError);
if (schemesCacheAdapter.schemes && schemesCacheAdapter.schemes.length > 0) {
availableSchemes = schemesCacheAdapter.schemes;
Logger.i("ColorSchemeDownload", "Using cached schemes due to rate limit");
if (typeof ShellState !== 'undefined' && ShellState.isLoaded) {
const cacheData = ShellState.getColorSchemesList();
const cachedSchemes = cacheData.schemes || [];
if (cachedSchemes.length > 0) {
availableSchemes = cachedSchemes;
hasInitialData = true;
Logger.i("ColorSchemeDownload", "Using cached schemes due to rate limit");
}
}
} else {
downloadError = I18n.tr("settings.color-scheme.download.error.api-error", {
@@ -740,7 +745,12 @@ Popup {
enabled: !fetching && !downloading
onClicked: {
// Force refresh by clearing cache timestamp and fetching directly from API
schemesCacheAdapter.timestamp = 0;
if (typeof ShellState !== 'undefined' && ShellState.isLoaded) {
ShellState.setColorSchemesList({
schemes: [],
timestamp: 0
});
}
// Fetch directly from API to avoid cache check delay
fetchAvailableSchemesFromAPI();
}
+7 -2
View File
@@ -329,6 +329,11 @@ Singleton {
// ================================================================================
// TERMINAL THEMES (predefined schemes use pre-rendered files)
// ================================================================================
function escapeShellPath(path) {
// Escape single quotes by ending the quoted string, adding an escaped quote, and starting a new quoted string
return "'" + path.replace(/'/g, "'\\''") + "'";
}
function handleTerminalThemes(mode) {
const commands = [];
const homeDir = Quickshell.env("HOME");
@@ -339,8 +344,8 @@ Singleton {
const outputDir = outputPath.substring(0, outputPath.lastIndexOf('/'));
const templatePath = getTerminalColorsTemplate(terminal, mode);
commands.push(`mkdir -p ${outputDir}`);
commands.push(`cp -f ${templatePath} ${outputPath}`);
commands.push(`mkdir -p ${escapeShellPath(outputDir)}`);
commands.push(`cp -f ${escapeShellPath(templatePath)} ${escapeShellPath(outputPath)}`);
commands.push(`${TemplateRegistry.colorsApplyScript} ${terminal}`);
}
});