Changing the method name from "triggerMessage" to "displayActionMessage".

Generally speaking, I like to call the message at the bottom an "action message".
And things can "trigger" it, but in the case of a method that actually proactively displays the message, I find "displayActionMessage" to be a better name.

Also, removing package-lock files and improving code style
This commit is contained in:
David Négrier 2021-08-04 19:31:17 +02:00
parent 82832b7055
commit d1e5d57459
12 changed files with 81 additions and 9020 deletions

View file

@ -1,10 +1,10 @@
import { isButtonClickedEvent } from '../Events/ButtonClickedEvent';
import { isMenuItemClickedEvent } from '../Events/ui/MenuItemClickedEvent';
import { IframeApiContribution, sendToWorkadventure } from './IframeApiContribution';
import { apiCallback } from './registeredCallbacks';
import type { ButtonClickedCallback, ButtonDescriptor } from './Ui/ButtonDescriptor';
import { Popup } from './Ui/Popup';
import { TriggerMessage } from './Ui/TriggerMessage';
import { isButtonClickedEvent } from "../Events/ButtonClickedEvent";
import { isMenuItemClickedEvent } from "../Events/ui/MenuItemClickedEvent";
import { IframeApiContribution, sendToWorkadventure } from "./IframeApiContribution";
import { apiCallback } from "./registeredCallbacks";
import type { ButtonClickedCallback, ButtonDescriptor } from "./Ui/ButtonDescriptor";
import { Popup } from "./Ui/Popup";
import { ActionMessage } from "./Ui/ActionMessage";
let popupId = 0;
const popups: Map<number, Popup> = new Map<number, Popup>();
@ -26,7 +26,7 @@ interface ZonedPopupOptions {
export class WorkAdventureUiCommands extends IframeApiContribution<WorkAdventureUiCommands> {
callbacks = [
apiCallback({
type: 'buttonClickedEvent',
type: "buttonClickedEvent",
typeChecker: isButtonClickedEvent,
callback: (payloadData) => {
const callback = popupCallbacks.get(payloadData.popupId)?.get(payloadData.buttonId);
@ -40,7 +40,7 @@ export class WorkAdventureUiCommands extends IframeApiContribution<WorkAdventure
},
}),
apiCallback({
type: 'menuItemClicked',
type: "menuItemClicked",
typeChecker: isMenuItemClickedEvent,
callback: (event) => {
const callback = menuCallbacks.get(event.menuItem);
@ -68,7 +68,7 @@ export class WorkAdventureUiCommands extends IframeApiContribution<WorkAdventure
}
sendToWorkadventure({
type: 'openPopup',
type: "openPopup",
data: {
popupId,
targetObject,
@ -89,7 +89,7 @@ export class WorkAdventureUiCommands extends IframeApiContribution<WorkAdventure
registerMenuCommand(commandDescriptor: string, callback: (commandDescriptor: string) => void) {
menuCallbacks.set(commandDescriptor, callback);
sendToWorkadventure({
type: 'registerMenuCommand',
type: "registerMenuCommand",
data: {
menutItem: commandDescriptor,
},
@ -97,15 +97,15 @@ export class WorkAdventureUiCommands extends IframeApiContribution<WorkAdventure
}
displayBubble(): void {
sendToWorkadventure({ type: 'displayBubble', data: null });
sendToWorkadventure({ type: "displayBubble", data: null });
}
removeBubble(): void {
sendToWorkadventure({ type: 'removeBubble', data: null });
sendToWorkadventure({ type: "removeBubble", data: null });
}
triggerMessage(message: string, callback: () => void): TriggerMessage {
return new TriggerMessage(message, callback);
displayActionMessage(message: string, callback: () => void): ActionMessage {
return new ActionMessage(message, callback);
}
}