ASのremoveを追加、ウィジェットを動的でなく静的に設定

This commit is contained in:
harukin-expo-dev-env 2024-05-21 10:16:31 +00:00
parent f85c79ab2c
commit 9738b752fb
2 changed files with 6 additions and 7 deletions

View File

@ -6,7 +6,6 @@ import { InfoWidget } from "./InfoWidget";
import { AS } from "../../storageControl"; import { AS } from "../../storageControl";
export const nameToWidget = { export const nameToWidget = {
// Hello will be the **name** with which we will reference our widget.
JR_shikoku_train_info: TraInfoEXWidget, JR_shikoku_train_info: TraInfoEXWidget,
Info_Widget: InfoWidget, Info_Widget: InfoWidget,
}; };
@ -58,21 +57,20 @@ export async function widgetTaskHandler(props) {
case "WIDGET_UPDATE": case "WIDGET_UPDATE":
case "WIDGET_CLICK": case "WIDGET_CLICK":
case "WIDGET_RESIZED": case "WIDGET_RESIZED":
// Not needed for now
if (WidgetName === "JR_shikoku_train_info") { if (WidgetName === "JR_shikoku_train_info") {
const Widget = nameToWidget[WidgetName];
const { time, delayString } = await getDelayData(); const { time, delayString } = await getDelayData();
props.renderWidget(<Widget time={time} delayString={delayString} />); props.renderWidget(
<TraInfoEXWidget time={time} delayString={delayString} />
);
} else if (WidgetName === "Info_Widget") { } else if (WidgetName === "Info_Widget") {
const Widget = nameToWidget[WidgetName];
const { time, text } = await getInfoString(); const { time, text } = await getInfoString();
props.renderWidget(<Widget time={time} delayString={text} />); props.renderWidget(<InfoWidget time={time} delayString={text} />);
} }
break; break;
case "WIDGET_DELETED": case "WIDGET_DELETED":
// Not needed for now AS.removeItem(`widgetType/${props.widgetInfo.widgetId}`);
break; break;
default: default:
break; break;

View File

@ -11,4 +11,5 @@ export const AS = {
// if set to null, then it will never expire. // if set to null, then it will never expire.
expires: null, expires: null,
}), }),
removeItem: (key) => storage.remove({ key }),
}; };