Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fcb35f1e40 | |||
| 048c2edb9b | |||
| f7096108f0 | |||
| de8aa503ba | |||
| d5ca679865 | |||
| 9362d110a5 | |||
| 2e94702ec2 | |||
| 709caf208a | |||
| 70fe066cdd | |||
| 73f456ed00 | |||
| c9431f62ef | |||
| b91f7fcfba | |||
| 58b25b0a44 | |||
| 01ed427b54 | |||
| 8fd37ec556 |
@@ -5,7 +5,6 @@ import { NavController } from 'ionic-angular';
|
||||
import { ChatPage } from '../chat/chat';
|
||||
import { ProfileService } from '../../services/profiles';
|
||||
import { ProfilePage } from '../profile/profile';
|
||||
import { TellYourStoryPage } from '../tell/tell';
|
||||
|
||||
@Component({
|
||||
selector: 'page-grid',
|
||||
@@ -18,8 +17,9 @@ export class GridPage {
|
||||
tabNavEl: any;
|
||||
|
||||
constructor(public navCtrl: NavController, public profileService: ProfileService, private _sanitizer: DomSanitizer) {
|
||||
profileService.load().then((data) => {
|
||||
profileService.loadVerified().then((data) => {
|
||||
this.profiles = data;
|
||||
console.debug('profiles: ', this.profiles);
|
||||
});
|
||||
this.tabNavEl = document.querySelector('#tab-nav .tabbar');
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ export class ProfileService {
|
||||
}
|
||||
|
||||
loadSubmitted() {
|
||||
if (this.profiles) {
|
||||
return Promise.resolve(this.profiles);
|
||||
if (this.profiles && this.profiles.submitted) {
|
||||
return Promise.resolve(this.profiles.submitted);
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
@@ -39,8 +39,8 @@ export class ProfileService {
|
||||
}
|
||||
|
||||
loadVerified() {
|
||||
if (this.profiles) {
|
||||
return Promise.resolve(this.profiles);
|
||||
if (this.profiles && this.profiles.verified) {
|
||||
return Promise.resolve(this.profiles.verified);
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
@@ -53,34 +53,34 @@ export class ProfileService {
|
||||
.map(res => res.json())
|
||||
.subscribe(
|
||||
data => {
|
||||
this.profiles = {};
|
||||
this.profiles = this.profiles || {};
|
||||
this.profiles[type] = data;
|
||||
this.profiles.reduce((map, profile, i) => {
|
||||
this.profiles[type].reduce((map, profile, i) => {
|
||||
map[profile._id] = i;
|
||||
return map;
|
||||
}, this.idMap[type]);
|
||||
resolve(this.profiles[type]);
|
||||
},
|
||||
error => {
|
||||
this.doGetRequest(this.fallback, resolve);
|
||||
this.doGetRequest(this.fallback, resolve, type);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
getNextProfile(id, type) {
|
||||
var nextIdIndex = this.idMap[id] + 1;
|
||||
nextIdIndex = nextIdIndex >= this.profiles.length ? 0 : nextIdIndex;
|
||||
return this.profiles[nextIdIndex];
|
||||
getNextProfile(id, type = 'all') {
|
||||
var nextIdIndex = this.idMap[type][id] + 1;
|
||||
nextIdIndex = nextIdIndex >= this.profiles[type].length ? 0 : nextIdIndex;
|
||||
return this.profiles[type][nextIdIndex];
|
||||
}
|
||||
|
||||
getPreviousProfile(id, type) {
|
||||
var prevIdIndex = this.idMap[id] + 1;
|
||||
prevIdIndex = prevIdIndex < 0 ? (this.profiles.length - 1) : prevIdIndex;
|
||||
return this.profiles[prevIdIndex];
|
||||
getPreviousProfile(id, type = 'all') {
|
||||
var prevIdIndex = this.idMap[type][id] - 1;
|
||||
prevIdIndex = prevIdIndex < 0 ? (this.profiles[type].length - 1) : prevIdIndex;
|
||||
return this.profiles[type][prevIdIndex];
|
||||
}
|
||||
|
||||
getProfiles() {
|
||||
return this.profiles;
|
||||
return this.profiles.all;
|
||||
}
|
||||
|
||||
getProfileById(id) {
|
||||
@@ -88,10 +88,10 @@ export class ProfileService {
|
||||
}
|
||||
|
||||
getSubmittedProfiles() {
|
||||
|
||||
return this.profiles.submitted;
|
||||
}
|
||||
|
||||
getVerifiedProfiles() {
|
||||
|
||||
return this.profiles.verified;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user