From e0e26290d09cff1956353573109c96ef49b8b73e Mon Sep 17 00:00:00 2001 From: Wotuu Date: Fri, 25 Oct 2024 14:20:27 +0200 Subject: [PATCH] #2585 WIP fixing/upgrading live route synchronization --- .../Ajax/AjaxMapIconController.php | 4 +- .../Ajax/AjaxMappingModelBaseController.php | 8 +- .../listen/{ => models}/killzone/changed.js | 0 .../listen/{ => models}/killzone/deleted.js | 0 .../messagehandler/listen/killzone/changed.js | 17 --- .../messagehandler/listen/killzone/deleted.js | 16 --- .../listen/models/basemodelhandler.js | 38 ++++++ .../listen/models/killzone/changed.js | 27 +++++ .../listen/models/killzone/deleted.js | 29 +++++ .../listen/models/modelchangedhandler.js | 30 +++++ .../listen/models/modeldeletedhandler.js | 44 +++++++ .../echo/messagehandler/listen/npc/changed.js | 2 +- .../echo/messagehandler/listen/npc/deleted.js | 2 +- .../echo/messagehandler/messagehandler.js | 7 ++ .../js/custom/mapcontrols/echocontrols.js | 5 +- .../mapobjectgroups/killzonemapobjectgroup.js | 6 +- .../killzonepathmapobjectgroup.js | 2 +- .../custom/mapobjectgroups/mapobjectgroup.js | 111 +++++------------- .../mapobjectgroups/pathmapobjectgroup.js | 2 +- .../usermousepositionmapobjectgroup.js | 2 +- routes/channels.php | 9 +- webpack.mix.js | 11 +- 22 files changed, 235 insertions(+), 137 deletions(-) rename resources/assets/js/custom/echo/message/listen/{ => models}/killzone/changed.js (100%) rename resources/assets/js/custom/echo/message/listen/{ => models}/killzone/deleted.js (100%) delete mode 100644 resources/assets/js/custom/echo/messagehandler/listen/killzone/changed.js delete mode 100644 resources/assets/js/custom/echo/messagehandler/listen/killzone/deleted.js create mode 100644 resources/assets/js/custom/echo/messagehandler/listen/models/basemodelhandler.js create mode 100644 resources/assets/js/custom/echo/messagehandler/listen/models/killzone/changed.js create mode 100644 resources/assets/js/custom/echo/messagehandler/listen/models/killzone/deleted.js create mode 100644 resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js create mode 100644 resources/assets/js/custom/echo/messagehandler/listen/models/modeldeletedhandler.js diff --git a/app/Http/Controllers/Ajax/AjaxMapIconController.php b/app/Http/Controllers/Ajax/AjaxMapIconController.php index a81266d6d0..65c62ac4ec 100644 --- a/app/Http/Controllers/Ajax/AjaxMapIconController.php +++ b/app/Http/Controllers/Ajax/AjaxMapIconController.php @@ -110,7 +110,9 @@ public function store( $mapIcon->setLinkedAwakenedObeliskByMapIconId($validated['linked_awakened_obelisk_id']); // Only when icons that are not sticky to the map are saved $dungeonRoute?->touch(); - }); + }, + // Can be null, it will then default to the dungeon internally + $dungeonRoute); } /** diff --git a/app/Http/Controllers/Ajax/AjaxMappingModelBaseController.php b/app/Http/Controllers/Ajax/AjaxMappingModelBaseController.php index 3aa9c08052..edda8dc2dc 100644 --- a/app/Http/Controllers/Ajax/AjaxMappingModelBaseController.php +++ b/app/Http/Controllers/Ajax/AjaxMappingModelBaseController.php @@ -38,12 +38,13 @@ protected function storeModel( array $validated, string $modelClass, ?MappingModelInterface $model = null, - ?Closure $onSaveSuccess = null + ?Closure $onSaveSuccess = null, + ?Model $echoContext = null ): Model { $validated['mapping_version_id'] = $mappingVersion?->id; /** @var Model $modelClass */ - return DB::transaction(function () use ($validated, $modelClass, $model, $onSaveSuccess) { + return DB::transaction(function () use ($validated, $modelClass, $model, $onSaveSuccess, $echoContext) { /** @var Model|null $beforeModel */ $beforeModel = $model === null ? null : clone $model; @@ -68,7 +69,8 @@ protected function storeModel( } if (Auth::check()) { - broadcast(new ModelChangedEvent($model->floor->dungeon, Auth::getUser(), $model)); + $echoContext = $echoContext ?? $model->floor->dungeon; + broadcast(new ModelChangedEvent($echoContext, Auth::getUser(), $model)); } return $model; diff --git a/resources/assets/js/custom/echo/message/listen/killzone/changed.js b/resources/assets/js/custom/echo/message/listen/models/killzone/changed.js similarity index 100% rename from resources/assets/js/custom/echo/message/listen/killzone/changed.js rename to resources/assets/js/custom/echo/message/listen/models/killzone/changed.js diff --git a/resources/assets/js/custom/echo/message/listen/killzone/deleted.js b/resources/assets/js/custom/echo/message/listen/models/killzone/deleted.js similarity index 100% rename from resources/assets/js/custom/echo/message/listen/killzone/deleted.js rename to resources/assets/js/custom/echo/message/listen/models/killzone/deleted.js diff --git a/resources/assets/js/custom/echo/messagehandler/listen/killzone/changed.js b/resources/assets/js/custom/echo/messagehandler/listen/killzone/changed.js deleted file mode 100644 index b81534317f..0000000000 --- a/resources/assets/js/custom/echo/messagehandler/listen/killzone/changed.js +++ /dev/null @@ -1,17 +0,0 @@ -class KillZoneChangedHandler extends MessageHandler { - - constructor(echo) { - super(echo, '.killzone-changed'); - } - - - /** - * - * @param e {KillZoneChangedMessage} - */ - onReceive(e) { - super.onReceive(e); - - console.log(`KillZoneChangedHandler::onReceive:`, e); - } -} diff --git a/resources/assets/js/custom/echo/messagehandler/listen/killzone/deleted.js b/resources/assets/js/custom/echo/messagehandler/listen/killzone/deleted.js deleted file mode 100644 index 6ac8751694..0000000000 --- a/resources/assets/js/custom/echo/messagehandler/listen/killzone/deleted.js +++ /dev/null @@ -1,16 +0,0 @@ -class KillZoneDeletedHandler extends MessageHandler { - - constructor(echo) { - super(echo, '.killzone-deleted'); - } - - /** - * - * @param e {KillZoneDeletedMessage} - */ - onReceive(e) { - super.onReceive(e); - - console.log(`KillZoneDeletedHandler::onReceive: ${e.model_id} ${e.model_class}`); - } -} diff --git a/resources/assets/js/custom/echo/messagehandler/listen/models/basemodelhandler.js b/resources/assets/js/custom/echo/messagehandler/listen/models/basemodelhandler.js new file mode 100644 index 0000000000..03399cebfd --- /dev/null +++ b/resources/assets/js/custom/echo/messagehandler/listen/models/basemodelhandler.js @@ -0,0 +1,38 @@ +class BaseModelHandler extends MessageHandler { + + /** + * @protected + * + * @param echo {Echo} + * @param message {String} + */ + constructor(echo, message) { + super(echo, message); + } + + /** + * Basic checks for if a received echo event is applicable to this model handler. + * + * @param e {Object} + * @returns {boolean} + * @protected + */ + _shouldHandleEchoEvent(e) { + console.assert(this instanceof BaseModelHandler, 'this is not a BaseModelHandler', this); + + // Do not process events that WE fired + return e.user.public_key !== getState().getUser().public_key; + } + + + /** + * + * @param e + * @return boolean + */ + onReceive(e) { + super.onReceive(e); + + return this._shouldHandleChangedEchoEvent(e); + } +} diff --git a/resources/assets/js/custom/echo/messagehandler/listen/models/killzone/changed.js b/resources/assets/js/custom/echo/messagehandler/listen/models/killzone/changed.js new file mode 100644 index 0000000000..e8c6e0a5e3 --- /dev/null +++ b/resources/assets/js/custom/echo/messagehandler/listen/models/killzone/changed.js @@ -0,0 +1,27 @@ +class KillZoneChangedHandler extends ModelChangedHandler { + + constructor(echo) { + super(echo, KillZoneChangedMessage.getName()); + + } + + + /** + * + * @param e {KillZoneChangedMessage} + * @return boolean + */ + onReceive(e) { + let shouldHandle = super.onReceive(e); + + console.log(`KillZoneChangedHandler::onReceive:`, shouldHandle, e); + if (shouldHandle) { + let killZoneMapObjectGroup = this.echo.map.mapObjectGroupManager.getByName(MAP_OBJECT_GROUP_KILLZONE); + + let mapObject = killZoneMapObjectGroup.loadMapObject(e.model, null, e.user); + killZoneMapObjectGroup.setMapObjectVisibility(mapObject, true); + } + + return shouldHandle; + } +} diff --git a/resources/assets/js/custom/echo/messagehandler/listen/models/killzone/deleted.js b/resources/assets/js/custom/echo/messagehandler/listen/models/killzone/deleted.js new file mode 100644 index 0000000000..19650ec1a9 --- /dev/null +++ b/resources/assets/js/custom/echo/messagehandler/listen/models/killzone/deleted.js @@ -0,0 +1,29 @@ +class KillZoneDeletedHandler extends ModelDeletedHandler { + + constructor(echo) { + super(echo, KillZoneDeletedMessage.getName()); + } + + /** + * + * @param e {KillZoneDeletedMessage} + */ + onReceive(e) { + let shouldHandle = super.onReceive(e); + + console.log(`KillZoneDeletedHandler::onReceive: ${e.model_id} ${e.model_class}`); + + if (shouldHandle) { + + let killZoneMapObjectGroup = this.echo.map.mapObjectGroupManager.getByName(MAP_OBJECT_GROUP_KILLZONE); + + let mapObject = killZoneMapObjectGroup.findMapObjectById(e.model_id); + if (mapObject !== null) { + mapObject.localDelete(); + this._showDeletedFromEcho(mapObject, e.user); + } + } + + return shouldHandle; + } +} diff --git a/resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js b/resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js new file mode 100644 index 0000000000..4de2ce4e84 --- /dev/null +++ b/resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js @@ -0,0 +1,30 @@ +class ModelChangedHandler extends BaseModelHandler { + /** + * Checks if a received _changed_ event is applicable to this map object group. + * + * @param e {Object} + * @returns {boolean} + * @private + */ + _shouldHandleChangedEchoEvent(e) { + console.assert(this instanceof ModelChangedHandler, 'this is not a ModelChangedHandler', this); + console.assert(typeof e.model !== 'undefined', 'model was not defined in received event!', this, e); + console.assert(typeof e.model.floor_id !== 'undefined', 'model.floor_id was not defined in received event!', this, e); + + // floor -1 means it's omnipresent (such as killzones) + // @TODO support facades? + return this._shouldHandleEchoEvent(e) && (e.model.floor_id === getState().getCurrentFloor().id || e.model.floor_id === -1); + } + + + /** + * + * @param e {KillZoneChangedMessage} + * @return boolean + */ + onReceive(e) { + super.onReceive(e); + + return this._shouldHandleChangedEchoEvent(e); + } +} diff --git a/resources/assets/js/custom/echo/messagehandler/listen/models/modeldeletedhandler.js b/resources/assets/js/custom/echo/messagehandler/listen/models/modeldeletedhandler.js new file mode 100644 index 0000000000..54b348a416 --- /dev/null +++ b/resources/assets/js/custom/echo/messagehandler/listen/models/modeldeletedhandler.js @@ -0,0 +1,44 @@ +class ModelDeletedHandler extends BaseModelHandler { + + /** + * Checks if a received _deleted_ event is applicable to this map object group. + * + * @param e {Object} + * @returns {boolean} + * @private + */ + _shouldHandleDeletedEchoEvent(e) { + console.assert(this instanceof ModelDeletedHandler, 'this is not a ModelDeletedHandler', this); + console.assert(typeof e.model_id !== 'undefined', 'model_id was not defined in received event!', this, e); + + return this._shouldHandleEchoEvent(e); + } + + /** + * + * @param localMapObject {MapObject} + * @param user {Object} + * @protected + */ + _showDeletedFromEcho(localMapObject, user) { + console.assert(this instanceof ModelDeletedHandler, 'this is not a ModelDeletedHandler', this); + + let state = getState(); + if (state.isEchoEnabled() && state.getUser().public_key !== user.public_key && user.name !== null) { + showInfoNotification(lang.get('messages.echo_object_deleted_notification') + .replace('{object}', localMapObject.toString()) + .replace('{user}', user.name)); + } + } + + /** + * + * @param e {KillZoneDeletedMessage} + * @return boolean + */ + onReceive(e) { + super.onReceive(e); + + return this._shouldHandleDeletedEchoEvent(e); + } +} diff --git a/resources/assets/js/custom/echo/messagehandler/listen/npc/changed.js b/resources/assets/js/custom/echo/messagehandler/listen/npc/changed.js index 14404c22ef..bb76abd709 100644 --- a/resources/assets/js/custom/echo/messagehandler/listen/npc/changed.js +++ b/resources/assets/js/custom/echo/messagehandler/listen/npc/changed.js @@ -1,7 +1,7 @@ class NpcChangedHandler extends MessageHandler { constructor(echo) { - super(echo, '.npc-changed'); + super(echo, NpcChangedMessage.getName()); } diff --git a/resources/assets/js/custom/echo/messagehandler/listen/npc/deleted.js b/resources/assets/js/custom/echo/messagehandler/listen/npc/deleted.js index 0ff5bebcf8..852eb14332 100644 --- a/resources/assets/js/custom/echo/messagehandler/listen/npc/deleted.js +++ b/resources/assets/js/custom/echo/messagehandler/listen/npc/deleted.js @@ -1,7 +1,7 @@ class NpcDeletedHandler extends MessageHandler { constructor(echo) { - super(echo, '.npc-deleted'); + super(echo, NpcDeletedMessage.getName()); } diff --git a/resources/assets/js/custom/echo/messagehandler/messagehandler.js b/resources/assets/js/custom/echo/messagehandler/messagehandler.js index 19e1f2eb2f..dca94a9e14 100644 --- a/resources/assets/js/custom/echo/messagehandler/messagehandler.js +++ b/resources/assets/js/custom/echo/messagehandler/messagehandler.js @@ -3,6 +3,10 @@ * @property {String} message */ class MessageHandler extends Signalable { + /** + * @param echo {Echo} + * @param message {String} + */ constructor(echo, message) { super(); @@ -27,6 +31,7 @@ class MessageHandler extends Signalable { console.assert(this instanceof MessageHandler, 'this is not a MessageHandler', this); console.log(`Listening for ${this.getMessage()}`); + // console.log(presenceChannel); presenceChannel.listen(this.getMessage(), this.onReceive.bind(this)); } @@ -36,6 +41,8 @@ class MessageHandler extends Signalable { onReceive(e) { console.assert(this instanceof MessageHandler, 'this is not a MessageHandler', this); + console.log(`MessageHandler::onReceive:`, e); + // Try to re-map the received message to an object that we know of let message = new MessageFactory().create(e.__name, e); diff --git a/resources/assets/js/custom/mapcontrols/echocontrols.js b/resources/assets/js/custom/mapcontrols/echocontrols.js index 8401b8b992..e0fe43b355 100644 --- a/resources/assets/js/custom/mapcontrols/echocontrols.js +++ b/resources/assets/js/custom/mapcontrols/echocontrols.js @@ -23,8 +23,9 @@ class EchoControls extends MapControl { this._onEchoCursorsEnabledChanged(); this.mapControlOptions = { - onAdd: function (leafletMap) { + onAdd: function () { return jQuery('', { + // @TODO translate text: 'Connecting...' })[0]; } @@ -168,7 +169,7 @@ class EchoControls extends MapControl { cursorsEnabled: getState().getDungeonMap().options.edit, cursorsActive: getState().getEchoCursorsEnabled(), users: getState().getEcho().getUsers().slice(0, c.map.echo.userOverflowCount), - hasUsersOverflow: getState().getEcho().getUsers().length >= c.map.echo.userOverflowCount, + hasUsersOverflow: getState().getEcho().getUsers().length > c.map.echo.userOverflowCount, usersOverflow: getState().getEcho().getUsers().slice(c.map.echo.userOverflowCount), type: getState().getMapContext().getType(), })); diff --git a/resources/assets/js/custom/mapobjectgroups/killzonemapobjectgroup.js b/resources/assets/js/custom/mapobjectgroups/killzonemapobjectgroup.js index 64fb594f09..7706710746 100644 --- a/resources/assets/js/custom/mapobjectgroups/killzonemapobjectgroup.js +++ b/resources/assets/js/custom/mapobjectgroups/killzonemapobjectgroup.js @@ -15,9 +15,9 @@ class KillZoneMapObjectGroup extends MapObjectGroup { return getState().getMapContext().getKillZones(); } - _loadMapObject(remoteMapObject, layer = null, user = null) { + loadMapObject(remoteMapObject, layer = null, user = null) { /** @type {KillZone} */ - let mapObject = super._loadMapObject(remoteMapObject, layer, user); + let mapObject = super.loadMapObject(remoteMapObject, layer, user); // If this was received from Echo.. if (user !== null && remoteMapObject.lat !== null && remoteMapObject.lng !== null) { @@ -227,7 +227,7 @@ class KillZoneMapObjectGroup extends MapObjectGroup { } let lastKillZone = this._findLastKillZone(); - let killZone = this._loadMapObject({ + let killZone = this.loadMapObject({ color: c.map.killzone.polygonOptions.color(lastKillZone !== null ? lastKillZone.color : null), floor_id: null, // Only for the killzone location which is not set from a 'new pull' enemies: enemyIds, diff --git a/resources/assets/js/custom/mapobjectgroups/killzonepathmapobjectgroup.js b/resources/assets/js/custom/mapobjectgroups/killzonepathmapobjectgroup.js index 143b649f2d..8c3a81be2b 100644 --- a/resources/assets/js/custom/mapobjectgroups/killzonepathmapobjectgroup.js +++ b/resources/assets/js/custom/mapobjectgroups/killzonepathmapobjectgroup.js @@ -255,7 +255,7 @@ class KillZonePathMapObjectGroup extends PolylineMapObjectGroup { createNewPath(vertices, options) { console.assert(this instanceof KillZonePathMapObjectGroup, 'this is not a KillZonePathMapObjectGroup', this); - let path = this._loadMapObject($.extend(true, {}, { + let path = this.loadMapObject($.extend(true, {}, { id: this.currentId++, polyline: { color: c.map.polyline.killzonepath.color, diff --git a/resources/assets/js/custom/mapobjectgroups/mapobjectgroup.js b/resources/assets/js/custom/mapobjectgroups/mapobjectgroup.js index ba12fb2332..e67680b688 100644 --- a/resources/assets/js/custom/mapobjectgroups/mapobjectgroup.js +++ b/resources/assets/js/custom/mapobjectgroups/mapobjectgroup.js @@ -38,7 +38,7 @@ class MapObjectGroup extends Signalable { // Callback to when the manager has received data from the server this.manager.map.register('map:beforerefresh', this, this._onBeforeRefresh.bind(this)); // Whenever the map refreshes, we need to add ourselves to the map again - this.manager.map.register('map:refresh', this, (function (mapRefreshEvent) { + this.manager.map.register('map:refresh', this, (function () { // Rebuild the layer group self.layerGroup = new L.LayerGroup(); }).bind(this)); @@ -49,28 +49,28 @@ class MapObjectGroup extends Signalable { } // @TODO Convert this to the new echo message system - if (getState().isEchoEnabled()) { - let presenceChannel = window.Echo.join(getState().getMapContext().getEchoChannelName()); - - for (let index in this.names) { - if (this.names.hasOwnProperty(index)) { - presenceChannel.listen(`.${this.names[index]}-changed`, (e) => { - if (self._shouldHandleChangedEchoEvent(e)) { - let mapObject = self._loadMapObject(e.model, null, e.user); - self.setMapObjectVisibility(mapObject, true); - } - }).listen(`.${this.names[index]}-deleted`, (e) => { - if (self._shouldHandleDeletedEchoEvent(e)) { - let mapObject = self.findMapObjectById(e.model_id); - if (mapObject !== null) { - mapObject.localDelete(); - self._showDeletedFromEcho(mapObject, e.user); - } - } - }); - } - } - } + // if (getState().isEchoEnabled()) { + // let presenceChannel = window.Echo.join(getState().getMapContext().getEchoChannelName()); + // + // for (let index in this.names) { + // if (this.names.hasOwnProperty(index)) { + // presenceChannel.listen(`.${this.names[index]}-changed`, (e) => { + // if (self._shouldHandleChangedEchoEvent(e)) { + // let mapObject = self.loadMapObject(e.model, null, e.user); + // self.setMapObjectVisibility(mapObject, true); + // } + // }).listen(`.${this.names[index]}-deleted`, (e) => { + // if (self._shouldHandleDeletedEchoEvent(e)) { + // let mapObject = self.findMapObjectById(e.model_id); + // if (mapObject !== null) { + // mapObject.localDelete(); + // self._showDeletedFromEcho(mapObject, e.user); + // } + // } + // }); + // } + // } + // } } /** @@ -89,46 +89,6 @@ class MapObjectGroup extends Signalable { console.error('Implement _getRawObjects()!'); } - /** - * Basic checks for if a received echo event is applicable to this map object group. - * @param e {Object} - * @returns {boolean} - * @private - */ - _shouldHandleEchoEvent(e) { - console.assert(this instanceof MapObjectGroup, 'this is not a MapObjectGroup', this); - - return e.user.public_key !== getState().getUser().public_key; - } - - /** - * Checks if a received _changed_ event is applicable to this map object group. - * @param e {Object} - * @returns {boolean} - * @private - */ - _shouldHandleChangedEchoEvent(e) { - console.assert(this instanceof MapObjectGroup, 'this is not a MapObjectGroup', this); - console.assert(typeof e.model !== 'undefined', 'model was not defined in received event!', this, e); - console.assert(typeof e.model.floor_id !== 'undefined', 'model.floor_id was not defined in received event!', this, e); - - // floor -1 means it's omnipresent (such as killzones) - return this._shouldHandleEchoEvent(e) && (e.model.floor_id === getState().getCurrentFloor().id || e.model.floor_id === -1); - } - - /** - * Checks if a received _deleted_ event is applicable to this map object group. - * @param e {Object} - * @returns {boolean|boolean} - * @private - */ - _shouldHandleDeletedEchoEvent(e) { - console.assert(this instanceof MapObjectGroup, 'this is not a MapObjectGroup', this); - console.assert(typeof e.model_id !== 'undefined', 'model_id was not defined in received event!', this, e); - - return this._shouldHandleEchoEvent(e); - } - /** * Triggered when the seasonal index was changed. * @param seasonalIndexChangedEvent {object} @@ -250,15 +210,14 @@ class MapObjectGroup extends Signalable { } /** - * Restores an object that was received from the server. + * Restores an object that was received from the server/Echo. * * @param remoteMapObject {object} * @param layer {L.layer|null} Optional layer that was created already * @param user {Object|null} The user that created this object (if done from Echo) * @return {MapObject} - * @protected */ - _loadMapObject(remoteMapObject, layer = null, user = null) { + loadMapObject(remoteMapObject, layer = null, user = null) { console.assert(this instanceof MapObjectGroup, 'this is not a MapObjectGroup', this); let mapObject = this.findMapObjectById(remoteMapObject.id); @@ -381,22 +340,6 @@ class MapObjectGroup extends Signalable { } } - /** - * - * @param localMapObject {MapObject} - * @param user {Object} - * @protected - */ - _showDeletedFromEcho(localMapObject, user) { - console.assert(this instanceof MapObjectGroup, 'this is not a MapObjectGroup', this); - - if (getState().isEchoEnabled() && getState().getUser().public_key !== user.public_key && user.name !== null) { - showInfoNotification(lang.get('messages.echo_object_deleted_notification') - .replace('{object}', localMapObject.toString()) - .replace('{user}', user.name)); - } - } - /** * Called whenever a map object is initialized for the first time * @param objectInitializedEvent {object} @@ -511,7 +454,7 @@ class MapObjectGroup extends Signalable { // Now draw the map objects on the map for (let i = 0; i < mapObjects.length; i++) { - this._loadMapObject(mapObjects[i]); + this.loadMapObject(mapObjects[i]); } this._initialized = true; @@ -666,7 +609,7 @@ class MapObjectGroup extends Signalable { onNewLayerCreated(layer) { console.assert(this instanceof MapObjectGroup, 'this was not a MapObjectGroup', this); - let createdMapObject = this._loadMapObject({id: -1}, layer); + let createdMapObject = this.loadMapObject({id: -1}, layer); // Make sure it's visible on the map this.setMapObjectVisibility(createdMapObject, true); diff --git a/resources/assets/js/custom/mapobjectgroups/pathmapobjectgroup.js b/resources/assets/js/custom/mapobjectgroups/pathmapobjectgroup.js index 76d59f943c..46e3a6ac21 100644 --- a/resources/assets/js/custom/mapobjectgroups/pathmapobjectgroup.js +++ b/resources/assets/js/custom/mapobjectgroups/pathmapobjectgroup.js @@ -28,7 +28,7 @@ class PathMapObjectGroup extends PolylineMapObjectGroup { * @returns {Path} */ createNewPath(vertices, options) { - let path = this._loadMapObject($.extend({}, { + let path = this.loadMapObject($.extend({}, { polyline: { color: c.map.polyline.awakenedObeliskGatewayPolylineColor, color_animated: getState().hasPatreonBenefit(c.patreonbenefits.animated_polylines) ? c.map.polyline.awakenedObeliskGatewayPolylineColorAnimated : null, diff --git a/resources/assets/js/custom/mapobjectgroups/usermousepositionmapobjectgroup.js b/resources/assets/js/custom/mapobjectgroups/usermousepositionmapobjectgroup.js index 1748bd4a31..d602fef810 100644 --- a/resources/assets/js/custom/mapobjectgroups/usermousepositionmapobjectgroup.js +++ b/resources/assets/js/custom/mapobjectgroups/usermousepositionmapobjectgroup.js @@ -45,7 +45,7 @@ class UserMousePositionMapObjectGroup extends MapObjectGroup { createNewUserMousePosition(echoUser) { console.assert(this instanceof UserMousePositionMapObjectGroup, 'this is not a UserMousePositionMapObjectGroup', this); - let userMousePosition = this._loadMapObject({ + let userMousePosition = this.loadMapObject({ id: echoUser.getPublicKey(), public_key: echoUser.getPublicKey(), initials: echoUser.getInitials(), diff --git a/routes/channels.php b/routes/channels.php index 6f4a568d60..15c9b9bbfc 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -27,6 +27,7 @@ if ($dungeonRoute === null) { return false; } + $result = false; if (Auth::check()) { if ($user->echo_anonymous && @@ -64,9 +65,13 @@ }; Broadcast::channel(sprintf('%s-route-edit.{dungeonRoute}', config('app.type')), $dungeonRouteChannelCallback); -Broadcast::channel(sprintf('%s-live-session.{liveSession}', config('app.type')), static fn(?User $user, LiveSession $liveSession) => $dungeonRouteChannelCallback($user, $liveSession->dungeonroute)); +Broadcast::channel(sprintf('%s-live-session.{liveSession}', config('app.type')), + static fn(?User $user, LiveSession $liveSession) => $dungeonRouteChannelCallback($user, $liveSession->dungeonroute) +); Broadcast::channel(sprintf('%s-route-compare.{dungeonRouteA}-{dungeonRouteB}', config('app.type')), - static fn(?User $user, DungeonRoute $dungeonRouteA, DungeonRoute $dungeonRouteB) => $dungeonRouteChannelCallback($user, $dungeonRouteA) && $dungeonRouteChannelCallback($user, $dungeonRouteB)); + static fn(?User $user, DungeonRoute $dungeonRouteA, DungeonRoute $dungeonRouteB) => + $dungeonRouteChannelCallback($user, $dungeonRouteA) && $dungeonRouteChannelCallback($user, $dungeonRouteB) +); Broadcast::channel(sprintf('%s-mapping-version-edit.{dungeon}', config('app.type')), static function (User $user, Dungeon $dungeon) { $result = false; diff --git a/webpack.mix.js b/webpack.mix.js index 1a85822957..d75cffafd5 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -170,10 +170,10 @@ let scripts = [ // Echo messages 'resources/assets/js/custom/echo/message/message.js', - 'resources/assets/js/custom/echo/message/listen/killzone/changed.js', - 'resources/assets/js/custom/echo/message/listen/killzone/deleted.js', 'resources/assets/js/custom/echo/message/listen/livesession/invite.js', 'resources/assets/js/custom/echo/message/listen/livesession/stop.js', + 'resources/assets/js/custom/echo/message/listen/models/killzone/changed.js', + 'resources/assets/js/custom/echo/message/listen/models/killzone/deleted.js', 'resources/assets/js/custom/echo/message/listen/npc/changed.js', 'resources/assets/js/custom/echo/message/listen/npc/deleted.js', 'resources/assets/js/custom/echo/message/listen/overpulledenemy/changed.js', @@ -185,10 +185,13 @@ let scripts = [ // Echo message handlers 'resources/assets/js/custom/echo/messagehandler/messagehandler.js', 'resources/assets/js/custom/echo/messagehandler/listen/colorchanged.js', - 'resources/assets/js/custom/echo/messagehandler/listen/killzone/changed.js', - 'resources/assets/js/custom/echo/messagehandler/listen/killzone/deleted.js', 'resources/assets/js/custom/echo/messagehandler/listen/livesession/invite.js', 'resources/assets/js/custom/echo/messagehandler/listen/livesession/stop.js', + 'resources/assets/js/custom/echo/messagehandler/listen/models/basemodelhandler.js', + 'resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js', + 'resources/assets/js/custom/echo/messagehandler/listen/models/modeldeletedhandler.js', + 'resources/assets/js/custom/echo/messagehandler/listen/models/killzone/changed.js', + 'resources/assets/js/custom/echo/messagehandler/listen/models/killzone/deleted.js', 'resources/assets/js/custom/echo/messagehandler/listen/overpulledenemy/changed.js', 'resources/assets/js/custom/echo/messagehandler/listen/overpulledenemy/deleted.js', 'resources/assets/js/custom/echo/messagehandler/listen/npc/changed.js',