Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit ff89634

Browse files
Merge pull request #280 from microsoft/users/t-xunguy/default-clue
Swap broken picture when there is no images
2 parents 64a97be + d2ce028 commit ff89634

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/view/components/clue/ClueSimulator.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
// DEVICE_LIST_KEY,
55
CONSTANTS,
66
WEBVIEW_MESSAGES,
7+
DEFAULT_IMG_CLUE,
78
} from "../../constants";
89
import PlayLogo from "../../svgs/play_svg";
910
import StopLogo from "../../svgs/stop_svg";
@@ -13,7 +14,7 @@ import { BUTTONS_KEYS, ClueImage } from "./ClueImage";
1314

1415
const DEFAULT_CLUE_STATE: IClueState = {
1516
buttons: { button_a: false, button_b: false },
16-
displayMessage: "",
17+
displayMessage: DEFAULT_IMG_CLUE,
1718
};
1819

1920
interface IState {
@@ -66,6 +67,10 @@ export class ClueSimulator extends React.Component<any, IState> {
6667
this.setState({
6768
play_button: !this.state.play_button,
6869
running_file: newRunningFile,
70+
clue: {
71+
...this.state.clue,
72+
displayMessage: DEFAULT_IMG_CLUE,
73+
},
6974
});
7075
break;
7176
case "visible-editors":

src/view/components/clue/Clue_svg.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license.
33

44
import * as React from "react";
5-
import { DEFAULT_IMG_CLUE } from "../../constants";
65
import "../../styles/Clue.css";
76
export interface IRefObject {
87
[key: string]: React.RefObject<SVGRectElement>;
@@ -33,7 +32,6 @@ export class ClueSvg extends React.Component<IProps, {}> {
3332
}
3433
componentDidMount() {
3534
this.updateDisplay();
36-
this.setDefaultDisplay();
3735
}
3836
componentDidUpdate() {
3937
this.updateDisplay();
@@ -944,16 +942,11 @@ export class ClueSvg extends React.Component<IProps, {}> {
944942
);
945943
}
946944
private updateDisplay() {
947-
if (this.displayRef.current) {
945+
if (this.displayRef.current && this.props.displayImage) {
948946
this.displayRef.current.setAttribute(
949947
"href",
950948
`data:image/png;base64,${this.props.displayImage}`
951949
);
952950
}
953951
}
954-
private setDefaultDisplay() {
955-
if (this.displayRef.current) {
956-
this.displayRef.current.setAttribute("href", DEFAULT_IMG_CLUE);
957-
}
958-
}
959952
}

src/view/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export enum WEBVIEW_TYPES {
123123
SIMULATOR = "simulator",
124124
GETTING_STARTED = "getting_started",
125125
}
126-
export const DEFAULT_IMG_CLUE = `data:image/png;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAEBAQEBAQEBA
126+
export const DEFAULT_IMG_CLUE = `/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAEBAQEBAQEBA
127127
QEBAQEBAQICAQEBAQMCAgICAwMEBAMDAwMEBAYFBAQFBAMDBQcFBQYGBgYGBAUHBwcGBwYGBgb/2wBDAQEBAQEBAQMCAgMGBAMEB
128128
gYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgb/wAARCAJYAlgDASIAAhEBAxEB/8QAHwAAA
129129
QUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0Kxw

0 commit comments

Comments
 (0)