Commit fc24568e authored by Jie Yuan's avatar Jie Yuan
Browse files

make the refresh behavior in site view correct

parent 77bc4d46
......@@ -18,7 +18,15 @@ export class SiteComponent implements OnInit, OnDestroy {
public router: Router,
public route: ActivatedRoute
) {
console.log('in site view constructor');
this.site = this.siteService.getCurrentSelectedSite();
console.log(this.site);
// if ( this.site === null || this.site === undefined ) {
// const tmp = sessionStorage.getItem('currentSelectedSite');
// if ( tmp !== null && tmp !== '' && tmp !== undefined) {
// this.site = JSON.parse(tmp);
// }
//}
this.siteUpdateSubscription = this.siteService.siteSubscription.subscribe(
(newSite: Site) => {
this.site = newSite;
......
......@@ -116,11 +116,20 @@ export class SiteService {
setSelectedSite(newSelectedSite: Site) {
this.currentSelectedSite = newSelectedSite;
sessionStorage.setItem('currentSelectedSite', JSON.stringify(this.currentSelectedSite));
this.siteSubscription.emit(newSelectedSite);
}
getCurrentSelectedSite() {
return this.currentSelectedSite;
if (this.currentSelectedSite !== null && this.currentSelectedSite !== undefined) {
return this.currentSelectedSite;
} else {
const tmp = sessionStorage.getItem('currentSelectedSite');
if ( tmp !== null && tmp !== '' && tmp !== undefined) {
this.currentSelectedSite = JSON.parse(tmp);
return this.currentSelectedSite;
}
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment