lml-main
Version:
This is now a mono repository published into many standalone packages.
32 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var cosmo_redux_api_1 = require("@lml/cosmo-redux-api");
var actions_1 = require("../actions");
exports.subscribeToPings = function (action$, store) {
return action$.ofType(actions_1.PUSHER_CONNECTION_SUCCESS)
.mapTo(actions_1.pusherSubscribeChannel('ping', 'COURIER_PING', function (message) {
var objectId = message.objectId, refId = message.refId, latitude = message.latitude, longitude = message.longitude, timestamp = message.timestamp;
var location = {
objectId: objectId,
refId: refId,
position: {
type: 'point',
coordinates: {
latitude: latitude,
longitude: longitude,
}
},
timestamp: timestamp,
};
return cosmo_redux_api_1.setLocationByObjectId(location);
// it's possible to do this so that we only care
// about saving the courier's location if they are in the state already
// const state = store.getState()
// const courier = getCourierById(state, objectId)
// if (courier) {
// } else {
// return { type: 'COURIER_NOT_IN_STATE ' }
// }
}));
};
//# sourceMappingURL=couriers.js.map