(function () { "use strict"; var SharingManager = function ($scope, sharingService, userService) { $('.waiting').hide(); $scope.newConnection = false; $scope.newEmail = false; $scope.requestConfirmationText = ''; $scope.emailClaimText = ''; $scope.reload = 1; function GetData() { sharingService.getConnectionRequests().then(function (data) { $scope.requests = data.data; }); $scope.reload++; } $scope.getData = GetData; GetData(); $scope.requestConnection = function () { $scope.newConnection = true; }; $scope.cancelRequest = function (request) { sharingService.cancelSharingRequest(request.RequestId).then(() => request.hidden = true ); }; $scope.remind = function (request) { request.canSend = false; request.UpdatedAt = ''; sharingService.sendReminder(request.RequestId).then(() => { request.UpdatedAt = labelDate(new Date(), 0); request.canSend = false; }); }; userService.planCount().then(count => { $scope.familyPlanLeft = count }); sharingService.getOutstandingInvitations().then(function (data) { $scope.outstanding = data.data.map(x => { x.UpdatedAt = labelDate(x.UpdatedAt, 0); return x; }); }); $scope.confirm = function (connection) { sharingService.confirmConnection(connection.Name, connection.Token).then(function (data) { connection.next = GetData; connection.sharedTags = data.Tags; connection.id = data.Viewer.Id; connection.name = data.Viewer.Name; connection.accepted = true; }); }; $scope.ignore = function (connection) { sharingService.ignoreConnection(connection.Token).then(function (data) { GetData(); }).catch(); }; }; SharingManager.$inject = ['$scope', 'sharingService','userService']; angular.module('streamApp').controller('sharingController', SharingManager); })();