Skip to content

Commit

Permalink
Load Theme in Version History Preview (#10413)
Browse files Browse the repository at this point in the history
Fixes microsoft/pxt-arcade#6303 by sending a set-theme message when initializing version history.
  • Loading branch information
thsparks authored Mar 7, 2025
1 parent 2a92131 commit 0e55453
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion webapp/src/timeMachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { hideDialog, warningNotification } from "./core";
import { FocusTrap } from "../../react-common/components/controls/FocusTrap";
import { classList } from "../../react-common/components/util";
import { HistoryFile, applySnapshot, patchConfigEditorVersion } from "../../pxteditor/history";
import { ThemeManager } from "../../react-common/components/theming/themeManager";

import ScriptText = pxt.workspace.ScriptText;

Expand Down Expand Up @@ -151,6 +152,18 @@ export const TimeMachine = (props: TimeMachineProps) => {

importProject.current = loadProject;

// Sync iframe theme with main theme.
const themeManager = ThemeManager.getInstance(document);
const currentTheme = themeManager.getCurrentColorTheme();
if (currentTheme) {
sendMessageAsync({
type: "pxteditor",
action: "setcolorthemebyid",
colorThemeId: currentTheme.id,
savePreference: false
} as pxt.editor.EditorMessageSetColorThemeRequest);
}

window.addEventListener("message", onMessageReceived);
return () => {
window.removeEventListener("message", onMessageReceived);
Expand Down Expand Up @@ -528,4 +541,4 @@ function getTimelineEntries(history: HistoryFile): TimelineEntry[] {
entries: buckets[key]
} as TimelineEntry
))
}
}

0 comments on commit 0e55453

Please sign in to comment.