mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
e035d526d6
Restructure frontend directories GitOrigin-RevId: 5a1224ca186f4809df45680a80d374c1c318d7bf
59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
/* eslint-disable
|
|
camelcase,
|
|
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:
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
*/
|
|
define(['base'], App =>
|
|
App.controller('AnnouncementsController', function(
|
|
$scope,
|
|
$http,
|
|
eventTracking,
|
|
$window,
|
|
_
|
|
) {
|
|
$scope.announcements = []
|
|
$scope.ui = {
|
|
isOpen: false,
|
|
newItems: 0
|
|
}
|
|
|
|
const refreshAnnouncements = () =>
|
|
$http.get('/announcements').then(function(response) {
|
|
$scope.announcements = response.data
|
|
return ($scope.ui.newItems = _.filter(
|
|
$scope.announcements,
|
|
announcement => !announcement.read
|
|
).length)
|
|
})
|
|
|
|
const markAnnouncementsAsRead = () =>
|
|
eventTracking.sendMB('announcement-alert-dismissed', {
|
|
blogPostId: $scope.announcements[0].id
|
|
})
|
|
|
|
$scope.logAnnouncementClick = () =>
|
|
eventTracking.sendMB('announcement-read-more-clicked', {
|
|
blogPostId: $scope.announcements[0].id
|
|
})
|
|
|
|
refreshAnnouncements()
|
|
|
|
$scope.toggleAnnouncementsUI = function() {
|
|
$scope.ui.isOpen = !$scope.ui.isOpen
|
|
|
|
if (!$scope.ui.isOpen && $scope.ui.newItems) {
|
|
$scope.ui.newItems = 0
|
|
return markAnnouncementsAsRead()
|
|
}
|
|
}
|
|
|
|
return ($scope.showAll = () => ($scope.ui.newItems = 0))
|
|
}))
|