ASのremoveを追加、ウィジェットを動的でなく静的に設定
This commit is contained in:
parent
f85c79ab2c
commit
9738b752fb
@ -6,7 +6,6 @@ import { InfoWidget } from "./InfoWidget";
|
||||
import { AS } from "../../storageControl";
|
||||
|
||||
export const nameToWidget = {
|
||||
// Hello will be the **name** with which we will reference our widget.
|
||||
JR_shikoku_train_info: TraInfoEXWidget,
|
||||
Info_Widget: InfoWidget,
|
||||
};
|
||||
@ -58,21 +57,20 @@ export async function widgetTaskHandler(props) {
|
||||
case "WIDGET_UPDATE":
|
||||
case "WIDGET_CLICK":
|
||||
case "WIDGET_RESIZED":
|
||||
// Not needed for now
|
||||
if (WidgetName === "JR_shikoku_train_info") {
|
||||
const Widget = nameToWidget[WidgetName];
|
||||
const { time, delayString } = await getDelayData();
|
||||
props.renderWidget(<Widget time={time} delayString={delayString} />);
|
||||
props.renderWidget(
|
||||
<TraInfoEXWidget time={time} delayString={delayString} />
|
||||
);
|
||||
} else if (WidgetName === "Info_Widget") {
|
||||
const Widget = nameToWidget[WidgetName];
|
||||
const { time, text } = await getInfoString();
|
||||
props.renderWidget(<Widget time={time} delayString={text} />);
|
||||
props.renderWidget(<InfoWidget time={time} delayString={text} />);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "WIDGET_DELETED":
|
||||
// Not needed for now
|
||||
AS.removeItem(`widgetType/${props.widgetInfo.widgetId}`);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -11,4 +11,5 @@ export const AS = {
|
||||
// if set to null, then it will never expire.
|
||||
expires: null,
|
||||
}),
|
||||
removeItem: (key) => storage.remove({ key }),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user