Merge pull request #2577 from overleaf/jel-notifications-decaf-cleanup

Decaf cleanup for notifications on dashboard

GitOrigin-RevId: ee8b30cf3af8078d8455bd85b89e6156f3993412
This commit is contained in:
Jessica Lawshe
2020-02-11 08:50:56 -06:00
committed by Copybot
parent 528b2b5728
commit 401ed57890

View File

@@ -1,32 +1,21 @@
/* eslint-disable
max-len,
no-return-assign,
no-undef,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const ExposedSettings = window.ExposedSettings
define(['base'], function(App) {
App.controller('NotificationsController', function($scope, $http) {
for (let notification of Array.from($scope.notifications)) {
for (let notification of $scope.notifications || []) {
notification.hide = false
}
$scope.samlInitPath = ExposedSettings.samlInitPath
return ($scope.dismiss = notification =>
$scope.dismiss = notification =>
$http({
url: `/notifications/${notification._id}`,
method: 'DELETE',
headers: {
'X-Csrf-Token': window.csrfToken
}
}).then(() => (notification.hide = true)))
}).then(() => (notification.hide = true))
})
App.controller('ProjectInviteNotificationController', function(
@@ -37,7 +26,7 @@ define(['base'], function(App) {
$scope.projectName = $scope.notification.messageOpts.projectName
$scope.userName = $scope.notification.messageOpts.userName
return ($scope.accept = function() {
$scope.accept = function() {
$scope.notification.inflight = true
return $http({
url: `/project/${
@@ -64,38 +53,10 @@ define(['base'], function(App) {
.finally(() => {
$scope.notification.inflight = false
})
})
}
})
App.controller('OverleafV2NotificationController', function(
$scope,
localStorage
) {
$scope.visible = !localStorage('overleaf_v2_2_notification_hidden_at')
return ($scope.dismiss = function() {
$scope.visible = false
return localStorage('overleaf_v2_2_notification_hidden_at', Date.now())
})
})
App.controller('OverleafV1NotificationController', function(
$scope,
localStorage
) {
$scope.visible = !localStorage('overleaf_v1_notification_hidden_at')
return ($scope.toggle = function() {
$scope.visible = !$scope.visible
if (!$scope.visible) {
return localStorage('overleaf_v1_notification_hidden_at', Date.now())
} else {
return localStorage('overleaf_v1_notification_hidden_at', null)
}
})
})
return App.controller('EmailNotificationController', function(
App.controller('EmailNotificationController', function(
$scope,
$http,
UserAffiliationsDataService
@@ -125,26 +86,26 @@ define(['base'], function(App) {
}
return false
}
for (let userEmail of Array.from($scope.userEmails)) {
for (let userEmail of $scope.userEmails) {
userEmail.hide = false
}
const _getUserEmails = () =>
UserAffiliationsDataService.getUserEmails().then(function(emails) {
$scope.userEmails = emails
return $scope.$emit('project-list:notifications-received')
$scope.$emit('project-list:notifications-received')
})
_getUserEmails()
return ($scope.resendConfirmationEmail = function(userEmail) {
$scope.resendConfirmationEmail = function(userEmail) {
userEmail.confirmationInflight = true
return UserAffiliationsDataService.resendConfirmationEmail(
userEmail.email
).then(function() {
userEmail.hide = true
userEmail.confirmationInflight = false
return $scope.$emit('project-list:notifications-received')
$scope.$emit('project-list:notifications-received')
})
})
}
})
})