1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

fixing network and network test error

This commit is contained in:
Braun Patrik 2017-06-22 21:23:26 +02:00
parent 4a96d2a0f9
commit c09052a2a5
3 changed files with 14 additions and 6 deletions

View File

@ -131,14 +131,18 @@ export class GalleryGridComponent implements OnChanges, AfterViewInit {
private renderedPhotoIndex: number = 0; private renderedPhotoIndex: number = 0;
private renderPhotos(numberOfPhotos: number = 0) { private renderPhotos(numberOfPhotos: number = 0) {
if (this.containerWidth == 0 || this.renderedPhotoIndex >= this.photos.length || !this.shouldRenderMore()) { if (this.containerWidth == 0 ||
this.renderedPhotoIndex >= this.photos.length ||
!this.shouldRenderMore()) {
return; return;
} }
let renderedContentHeight = 0; let renderedContentHeight = 0;
while (this.renderedPhotoIndex < this.photos.length && (this.shouldRenderMore(renderedContentHeight) === true || this.renderedPhotoIndex < numberOfPhotos)) { while (this.renderedPhotoIndex < this.photos.length &&
(this.shouldRenderMore(renderedContentHeight) === true ||
this.renderedPhotoIndex < numberOfPhotos)) {
let ret = this.renderARow(); let ret = this.renderARow();
if (ret === null) { if (ret === null) {
throw new Error("Gridphotos rendering failed"); throw new Error("Gridphotos rendering failed");
@ -150,7 +154,7 @@ export class GalleryGridComponent implements OnChanges, AfterViewInit {
/** /**
* Returns true, if scroll is >= 70% to render more images. * Returns true, if scroll is >= 70% to render more images.
* Or of onscroll renderin is off: return always to render all the images at once * Or of onscroll rendering is off: return always to render all the images at once
* @param offset Add height to the client height (conent is not yet added to the dom, but calculate with it) * @param offset Add height to the client height (conent is not yet added to the dom, but calculate with it)
* @returns {boolean} * @returns {boolean}
*/ */

View File

@ -4,6 +4,7 @@ import {MockBackend, MockConnection} from "@angular/http/testing";
import "rxjs/Rx"; import "rxjs/Rx";
import {NetworkService} from "./network.service"; import {NetworkService} from "./network.service";
import {Message} from "../../../../common/entities/Message"; import {Message} from "../../../../common/entities/Message";
import {SlimLoadingBarService} from "ng2-slim-loading-bar";
describe('NetworkService Success tests', () => { describe('NetworkService Success tests', () => {
@ -20,6 +21,7 @@ describe('NetworkService Success tests', () => {
providers: [ providers: [
MockBackend, MockBackend,
BaseRequestOptions, BaseRequestOptions,
SlimLoadingBarService,
{ {
provide: Http, useFactory: (backend, options) => { provide: Http, useFactory: (backend, options) => {
return new Http(backend, options); return new Http(backend, options);
@ -108,6 +110,8 @@ describe('NetworkService Fail tests', () => {
providers: [ providers: [
MockBackend, MockBackend,
BaseRequestOptions, BaseRequestOptions,
SlimLoadingBarService,
{ {
provide: Http, useFactory: (backend, options) => { provide: Http, useFactory: (backend, options) => {
return new Http(backend, options); return new Http(backend, options);

View File

@ -1,9 +1,9 @@
import {Injectable} from "@angular/core"; import {Injectable} from "@angular/core";
import {Headers, Http, RequestOptions} from "@angular/http"; import {Headers, Http, RequestOptions} from "@angular/http";
import {Message} from "../../../../common/entities/Message"; import {Message} from "../../../../common/entities/Message";
import {SlimLoadingBarService} from "ng2-slim-loading-bar";
import "rxjs/Rx"; import "rxjs/Rx";
import {SlimLoadingBarService} from "ng2-slim-loading-bar";
@Injectable() @Injectable()
export class NetworkService { export class NetworkService {
@ -28,8 +28,8 @@ export class NetworkService {
}; };
const err = (err) => { const err = (err) => {
NetworkService.handleError(err);
this.slimLoadingBarService.complete(); this.slimLoadingBarService.complete();
return NetworkService.handleError(err);
}; };
if (method == "get" || method == "delete") { if (method == "get" || method == "delete") {