mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +02:00
Keep forwards list up to date on client side.
This commit is contained in:
parent
b0400130ff
commit
fb3892ab07
2 changed files with 21 additions and 1 deletions
|
@ -505,6 +505,7 @@ module.exports = function(options) {
|
|||
}
|
||||
dbapi.addUserForward(user.email, data)
|
||||
.then(function() {
|
||||
socket.emit('forward.create', data)
|
||||
joinChannel(responseChannel)
|
||||
push.send([
|
||||
channel
|
||||
|
@ -518,6 +519,7 @@ module.exports = function(options) {
|
|||
.on('forward.remove', function(channel, responseChannel, data) {
|
||||
dbapi.removeUserForward(user.email, data.devicePort)
|
||||
.then(function() {
|
||||
socket.emit('forward.remove', data)
|
||||
joinChannel(responseChannel)
|
||||
push.send([
|
||||
channel
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function UserServiceFactory($http) {
|
||||
module.exports = function UserServiceFactory($http, $rootScope, socket) {
|
||||
var userService = {}
|
||||
|
||||
userService.user = (function () {
|
||||
|
@ -8,5 +8,23 @@ module.exports = function UserServiceFactory($http) {
|
|||
}
|
||||
})()
|
||||
|
||||
socket.on('forward.create', function(data) {
|
||||
userService.user().then(function(user) {
|
||||
$rootScope.$apply(function() {
|
||||
user.forwards.push(data)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
socket.on('forward.remove', function(data) {
|
||||
userService.user().then(function(user) {
|
||||
$rootScope.$apply(function() {
|
||||
user.forwards = user.forwards.filter(function(forward) {
|
||||
return forward.devicePort !== data.devicePort
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return userService
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue