app.repo("ServiceRepo", function ServiceRepo(WsApi) {

    var serviceRepo = this;

    var checkCreateNotes = function (service) {
        if (service.notes === undefined) {
            service.notes = [];
        }
    };

    var getNotesService = function (note) {
        var service = serviceRepo.findById(note.service.id);
        checkCreateNotes(service);
        return service;
    };

    serviceRepo.addNote = function (note) {
        if (note.pinned || note.active) {
            var service = getNotesService(note);
            service.notes.push(note);
        }
    };

    serviceRepo.updateNote = function (note) {
        var service = getNotesService(note);
        for (var i in service.notes) {
            if (service.notes[i].id === note.id) {
                if (note.pinned || note.active) {
                    angular.extend(service.notes[i], note);
                } else {
                    service.notes.splice(i, 1);
                }
                return;
            }
        }
        if (note.pinned || note.active) {
            service.notes.push(note);
        }
    };

    serviceRepo.removeNoteById = function (id) {
        var services = serviceRepo.getAll();
        for (var i in services) {
            checkCreateNotes(services[i]);
            for (var j in services[i].notes) {
                if (services[i].notes[j].id === id) {
                    services[i].notes.splice(j, 1);
                    return;
                }
            }
        }
    };

    WsApi.listen(serviceRepo.mapping.createListen).then(null, null, function (response) {
        serviceRepo.unshift(angular.fromJson(response.body).payload.Service);
    });

    WsApi.listen(serviceRepo.mapping.updateListen).then(null, null, function (response) {
        var updatedService = angular.fromJson(response.body).payload.Service;
        var service = serviceRepo.findById(updatedService.id);
        angular.extend(service, updatedService);
    });

    WsApi.listen(serviceRepo.mapping.deleteListen).then(null, null, function (response) {
        serviceRepo.remove(serviceRepo.findById(angular.fromJson(response.body).payload.Long));
    });

    return serviceRepo;

});

@@ -38,16 +38,26 @@
 iceRepo(
+$timeout, 
 WsApi) %7B
@@ -1611,32 +1611,35 @@
 ponse) %7B%0A       
+ //
  serviceRepo.uns
@@ -1685,32 +1685,113 @@
 yload.Service);%0A
+        $timeout(function () %7B%0A            serviceRepo.reset();%0A        %7D, 250);%0A
     %7D);%0A%0A    WsA
@@ -1876,24 +1876,27 @@
 e) %7B%0A       
+ //
  var updated
@@ -1953,32 +1953,35 @@
 Service;%0A       
+ //
  var service = s
@@ -2023,24 +2023,27 @@
 id);%0A       
+ //
  angular.ext
@@ -2068,24 +2068,105 @@
 edService);%0A
+        $timeout(function () %7B%0A            serviceRepo.reset();%0A        %7D, 250);%0A
     %7D);%0A%0A   
@@ -2255,24 +2255,27 @@
 e) %7B%0A       
+ //
  serviceRepo
@@ -2351,16 +2351,97 @@
 Long));%0A
+        $timeout(function () %7B%0A            serviceRepo.reset();%0A        %7D, 250);%0A
     %7D);%0A

reset service repo on broadcast change