overleaf/services/web/frontend/js/ide/share/controllers/ShareController.js
Alf Eaton 1be43911b4 Merge pull request #3942 from overleaf/prettier-trailing-comma
Set Prettier's "trailingComma" setting to "es5"

GitOrigin-RevId: 9f14150511929a855b27467ad17be6ab262fe5d5
2021-04-28 02:10:01 +00:00

55 lines
1.3 KiB
JavaScript

import App from '../../../base'
App.controller('ShareController', function (
$scope,
$modal,
ide,
projectInvites,
projectMembers,
// eslint-disable-next-line camelcase
eventTracking
) {
$scope.openShareProjectModal = function (isAdmin) {
$scope.isAdmin = isAdmin
eventTracking.sendMBOnce('ide-open-share-modal-once')
$modal.open({
templateUrl: 'shareProjectModalTemplate',
controller: 'ShareProjectModalController',
scope: $scope,
})
}
ide.socket.on('project:tokens:changed', data => {
if (data.tokens != null) {
ide.$scope.project.tokens = data.tokens
$scope.$digest()
}
})
ide.socket.on('project:membership:changed', data => {
if (data.members) {
projectMembers
.getMembers()
.then(response => {
if (response.data.members) {
$scope.project.members = response.data.members
}
})
.catch(() => {
console.error('Error fetching members for project')
})
}
if (data.invites) {
projectInvites
.getInvites()
.then(response => {
if (response.data.invites) {
$scope.project.invites = response.data.invites
}
})
.catch(() => {
console.error('Error fetching invites for project')
})
}
})
})