Skip to content

Commit 9623ec9

Browse files
Merge pull request #2 from anthonylau/master
fixed incorrect page when open file
2 parents 3c4576b + 7ffe241 commit 9623ec9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

hackfoldr/www/js/controllers.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@ console.log('$stateParams');
206206
// imageToDisplay
207207

208208
$scope.imageToDisplay;
209+
var fileIndex = parseInt($stateParams.fileId) - 1;
209210

210211
var displayedFiles = fileUtil.initDisplayedFiles(files);
211-
$scope.file = displayedFiles[parseInt($stateParams.fileId)];
212+
$scope.file = displayedFiles[fileIndex];
212213

213214
var key=md5Util.md5($scope.file.url);
214215

@@ -409,7 +410,8 @@ function($scope, $stateParams, files,$state,fileUtil) {
409410

410411
$scope.file = null;
411412
if(displayedFiles.length > 0){
412-
$scope.file = displayedFiles[parseInt($stateParams.fileId)];
413+
var fileIndex = parseInt($stateParams.fileId) - 1;
414+
$scope.file = displayedFiles[fileIndex];
413415

414416
var useApp = isUrlNoIframe($scope.file.url);
415417

@@ -419,7 +421,7 @@ function($scope, $stateParams, files,$state,fileUtil) {
419421

420422
var type = $scope.file.type;
421423
$scope.fileTitle = $scope.file.title;
422-
foldrService.current.fileIndex = parseInt($stateParams.fileId);
424+
foldrService.current.fileIndex = fileIndex;
423425
if (type === 'livestream') {
424426
console.log('update')
425427
$state.go("app.foldr.livestream", {

0 commit comments

Comments
 (0)