Skip to content

Commit

Permalink
Refresh new events in websockets on me view, Fix GladysAssistant#440 (G…
Browse files Browse the repository at this point in the history
…ladysAssistant#471)

* Fix GladysAssistant#440

Fix GladysAssistant#440 and reload scope when a new event was arrived

* Fix missing scope in front controller
  • Loading branch information
MathieuAndrade authored and Pierre-Gilles committed Jan 29, 2019
1 parent 3addc91 commit 668abba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions api/core/event/event.create.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ module.exports = function create(event){
return eventSaved;
})
.then((eventSaved) => {

if(!eventSaved.user) {
return eventSaved;
}

gladys.socket.emit('newEvent', {
id: eventSaved.id,
name: eventType.name,
Expand Down
8 changes: 5 additions & 3 deletions assets/js/app/event/event.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
.module('gladys')
.controller('EventCtrl', EventCtrl);

EventCtrl.$inject = ['eventService'];
EventCtrl.$inject = ['eventService', '$scope'];

function EventCtrl(eventService) {
function EventCtrl(eventService, $scope) {
/* jshint validthis: true */
var vm = this;
vm.events = [];
Expand Down Expand Up @@ -49,7 +49,9 @@
// waiting for websocket message
function waitForNewEvent() {
io.socket.on('newEvent', function (event) {
vm.events.unshift(event);
$scope.$apply(function(){
vm.events.unshift(event)
})
});
}

Expand Down

0 comments on commit 668abba

Please sign in to comment.