1
1
var papercutApp = angular . module ( 'papercutApp' , [ ] ) ;
2
2
3
3
4
- papercutApp . controller ( 'MailCtrl' , function ( $scope , $http , $sce , $timeout ) {
4
+ papercutApp . controller ( 'MailCtrl' , function ( $scope , $http , $sce , $timeout , $interval ) {
5
5
$scope . host = apiHost ;
6
6
7
7
$scope . cache = { } ;
@@ -136,6 +136,11 @@ papercutApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
136
136
} ) ;
137
137
}
138
138
$scope . refresh ( ) ;
139
+ $interval ( function ( ) {
140
+ if ( $scope . startIndex == 0 ) {
141
+ $scope . refresh ( ) ;
142
+ }
143
+ } , 8000 ) ;
139
144
140
145
$scope . showNewer = function ( ) {
141
146
$scope . startIndex -= $scope . itemsPerPage ;
@@ -160,33 +165,24 @@ papercutApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
160
165
$scope . refresh ( ) ;
161
166
}
162
167
163
- $scope . hasSelection = function ( ) {
164
- return $ ( ".messages :checked" ) . length > 0 ? true : false ;
165
- }
166
-
167
- $scope . selectMessage = function ( message ) {
168
- $timeout ( function ( ) {
169
- $scope . resizePreview ( ) ;
170
- } , 0 ) ;
171
- if ( $scope . cache [ message . Id ] ) {
172
- $scope . preview = $scope . cache [ message . Id ] ;
173
- //reflow();
174
- } else {
175
- $scope . preview = message ;
176
- var e = $scope . startEvent ( "Loading message" , message . Id , "glyphicon-download-alt" ) ;
177
- $http . get ( $scope . host + 'api/messages/' + message . Id ) . success ( function ( data ) {
178
- $scope . cache [ message . Id ] = data ;
179
-
180
- data . previewHTML = $sce . trustAsHtml ( data . HtmlBody ) ;
181
- $scope . preview = data ;
182
- e . done ( ) ;
183
- } ) ;
184
- }
185
- }
186
-
187
-
188
- $scope . fileSize = function ( bytes ) {
189
- return filesize ( bytes )
168
+ $scope . selectMessage = function ( message ) {
169
+ $timeout ( function ( ) {
170
+ $scope . resizePreview ( ) ;
171
+ } , 0 ) ;
172
+
173
+ if ( $scope . cache [ message . Id ] ) {
174
+ $scope . preview = $scope . cache [ message . Id ] ;
175
+ } else {
176
+ $scope . preview = message ;
177
+ var e = $scope . startEvent ( "Loading message" , message . Id , "glyphicon-download-alt" ) ;
178
+ $http . get ( $scope . host + 'api/messages/' + message . Id ) . success ( function ( data ) {
179
+ $scope . cache [ message . Id ] = data ;
180
+
181
+ data . previewHTML = $sce . trustAsHtml ( data . HtmlBody ) ;
182
+ $scope . preview = data ;
183
+ e . done ( ) ;
184
+ } ) ;
185
+ }
190
186
}
191
187
192
188
$scope . tryDecodeContent = function ( message ) {
0 commit comments