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 { ChatPage } from '../chat/chat';
|
||||||
import { ProfileService } from '../../services/profiles';
|
import { ProfileService } from '../../services/profiles';
|
||||||
import { ProfilePage } from '../profile/profile';
|
import { ProfilePage } from '../profile/profile';
|
||||||
import { TellYourStoryPage } from '../tell/tell';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-grid',
|
selector: 'page-grid',
|
||||||
@@ -18,8 +17,9 @@ export class GridPage {
|
|||||||
tabNavEl: any;
|
tabNavEl: any;
|
||||||
|
|
||||||
constructor(public navCtrl: NavController, public profileService: ProfileService, private _sanitizer: DomSanitizer) {
|
constructor(public navCtrl: NavController, public profileService: ProfileService, private _sanitizer: DomSanitizer) {
|
||||||
profileService.load().then((data) => {
|
profileService.loadVerified().then((data) => {
|
||||||
this.profiles = data;
|
this.profiles = data;
|
||||||
|
console.debug('profiles: ', this.profiles);
|
||||||
});
|
});
|
||||||
this.tabNavEl = document.querySelector('#tab-nav .tabbar');
|
this.tabNavEl = document.querySelector('#tab-nav .tabbar');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ export class ProfileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadSubmitted() {
|
loadSubmitted() {
|
||||||
if (this.profiles) {
|
if (this.profiles && this.profiles.submitted) {
|
||||||
return Promise.resolve(this.profiles);
|
return Promise.resolve(this.profiles.submitted);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -39,8 +39,8 @@ export class ProfileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadVerified() {
|
loadVerified() {
|
||||||
if (this.profiles) {
|
if (this.profiles && this.profiles.verified) {
|
||||||
return Promise.resolve(this.profiles);
|
return Promise.resolve(this.profiles.verified);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -53,34 +53,34 @@ export class ProfileService {
|
|||||||
.map(res => res.json())
|
.map(res => res.json())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.profiles = {};
|
this.profiles = this.profiles || {};
|
||||||
this.profiles[type] = data;
|
this.profiles[type] = data;
|
||||||
this.profiles.reduce((map, profile, i) => {
|
this.profiles[type].reduce((map, profile, i) => {
|
||||||
map[profile._id] = i;
|
map[profile._id] = i;
|
||||||
return map;
|
return map;
|
||||||
}, this.idMap[type]);
|
}, this.idMap[type]);
|
||||||
resolve(this.profiles[type]);
|
resolve(this.profiles[type]);
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this.doGetRequest(this.fallback, resolve);
|
this.doGetRequest(this.fallback, resolve, type);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getNextProfile(id, type) {
|
getNextProfile(id, type = 'all') {
|
||||||
var nextIdIndex = this.idMap[id] + 1;
|
var nextIdIndex = this.idMap[type][id] + 1;
|
||||||
nextIdIndex = nextIdIndex >= this.profiles.length ? 0 : nextIdIndex;
|
nextIdIndex = nextIdIndex >= this.profiles[type].length ? 0 : nextIdIndex;
|
||||||
return this.profiles[nextIdIndex];
|
return this.profiles[type][nextIdIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
getPreviousProfile(id, type) {
|
getPreviousProfile(id, type = 'all') {
|
||||||
var prevIdIndex = this.idMap[id] + 1;
|
var prevIdIndex = this.idMap[type][id] - 1;
|
||||||
prevIdIndex = prevIdIndex < 0 ? (this.profiles.length - 1) : prevIdIndex;
|
prevIdIndex = prevIdIndex < 0 ? (this.profiles[type].length - 1) : prevIdIndex;
|
||||||
return this.profiles[prevIdIndex];
|
return this.profiles[type][prevIdIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
getProfiles() {
|
getProfiles() {
|
||||||
return this.profiles;
|
return this.profiles.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
getProfileById(id) {
|
getProfileById(id) {
|
||||||
@@ -88,10 +88,10 @@ export class ProfileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSubmittedProfiles() {
|
getSubmittedProfiles() {
|
||||||
|
return this.profiles.submitted;
|
||||||
}
|
}
|
||||||
|
|
||||||
getVerifiedProfiles() {
|
getVerifiedProfiles() {
|
||||||
|
return this.profiles.verified;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user