Skip to content

Commit

Permalink
Block saving themes that overwrite built-in ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
thsparks committed Mar 1, 2025
1 parent 6c95bef commit 232d5c0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion themebuilder/src/components/ThemeEditorPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { exportTheme } from "../services/fileSystemService";
import { Button } from "react-common/components/controls/Button";
import { classList } from "react-common/components/util";
import * as auth from "../services/authClient";
import { ThemeManager } from "react-common/components/theming/themeManager";

export interface SaveState {
icon: string;
Expand Down Expand Up @@ -44,9 +45,17 @@ export const ThemeEditorPane = () => {
exportTheme(editingTheme);
}

// TODO thsparks : this should go into a service or transform
async function handleSaveToProfileClicked() {
if (!editingTheme) return;
const success = await auth.addCustomColorThemeAsync(editingTheme);

// Don't allow overwriting built-in themes
const builtinThemes = ThemeManager.getInstance(document).getAllColorThemes() || [];
let success = false;
if (!builtinThemes.find(t => t.id === editingTheme.id)) {
success = await auth.addCustomColorThemeAsync(editingTheme);
}

if (success) {
setTemporarySaveIcon(
{
Expand Down

0 comments on commit 232d5c0

Please sign in to comment.