start of post functions with bookmarks and reposts wired

This commit is contained in:
Morgan McMillian 2017-06-10 14:45:02 -07:00
parent ac0974d41c
commit fe25cf647e
4 changed files with 135 additions and 71 deletions

View file

@ -1,69 +1,69 @@
{
"name": "Goober",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.1.2",
"@angular/compiler": "4.1.2",
"@angular/compiler-cli": "4.1.2",
"@angular/core": "4.1.2",
"@angular/forms": "4.1.2",
"@angular/http": "4.1.2",
"@angular/platform-browser": "4.1.2",
"@angular/platform-browser-dynamic": "4.1.2",
"@ionic-native/core": "3.10.2",
"@ionic-native/splash-screen": "3.10.2",
"@ionic-native/status-bar": "3.10.2",
"@ionic/storage": "2.0.1",
"cordova-android": "^6.2.3",
"cordova-blackberry10": "^3.8.0",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-inappbrowser": "^1.7.1",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"cordova-windows": "^5.0.0",
"ionic-angular": "3.3.0",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"moment": "^2.18.1",
"ng2-cordova-oauth": "0.0.8",
"pnut-butter": "^0.8.1",
"rxjs": "5.1.1",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.11"
},
"devDependencies": {
"@ionic/app-scripts": "1.3.7",
"@ionic/cli-plugin-cordova": "1.3.0",
"@ionic/cli-plugin-ionic-angular": "1.3.0",
"typescript": "2.3.3"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-inappbrowser": {}
"name": "Goober",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"platforms": [
"android",
"blackberry10",
"windows"
]
}
}
"dependencies": {
"@angular/common": "4.1.2",
"@angular/compiler": "4.1.2",
"@angular/compiler-cli": "4.1.2",
"@angular/core": "4.1.2",
"@angular/forms": "4.1.2",
"@angular/http": "4.1.2",
"@angular/platform-browser": "4.1.2",
"@angular/platform-browser-dynamic": "4.1.2",
"@ionic-native/core": "3.10.2",
"@ionic-native/splash-screen": "3.10.2",
"@ionic-native/status-bar": "3.10.2",
"@ionic/storage": "2.0.1",
"cordova-android": "^6.2.3",
"cordova-blackberry10": "^3.8.0",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-inappbrowser": "^1.7.1",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"cordova-windows": "^5.0.0",
"ionic-angular": "3.3.0",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"moment": "^2.18.1",
"ng2-cordova-oauth": "0.0.8",
"pnut-butter": "^0.8.1",
"rxjs": "5.1.1",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.11"
},
"devDependencies": {
"@ionic/app-scripts": "1.3.7",
"@ionic/cli-plugin-cordova": "1.3.0",
"@ionic/cli-plugin-ionic-angular": "1.3.0",
"typescript": "2.3.3"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-inappbrowser": {}
},
"platforms": [
"android",
"blackberry10",
"windows"
]
}
}

View file

@ -42,8 +42,6 @@ export class MyApp {
}
}).catch(err => {
console.log('ERROR: ' + err);
pnut.token = 'DOLORSITAmET6E6uaqT70D8R8o-yAG2eqa48wBihEqYhWKN3WQzlIzBd4V18vI-OCjKWCwGUQDPlNO2sS9DgkyYMM0SbJAirYH';
this.nav.setRoot(StreamPage, {stream: 'global'});
});
this.platform.ready().then(() => {

View file

@ -41,24 +41,45 @@
<ion-row>
<ion-col>
<button ion-button icon-left clear small block>
<ion-icon name="text"></ion-icon>
</button>
</ion-col>
<ion-col>
<button ion-button icon-left clear small block>
<ion-icon name="quote"></ion-icon>
</button>
</ion-col>
<ion-col>
<button ion-button icon-left clear small block (click)="bookmark(post.id, post.you_bookmarked)">
<ion-icon name="star"></ion-icon>
<div *ngIf="post.counts.bookmarks > 0">{{ post.counts.bookmarks }}</div>
</button>
</ion-col>
<ion-col>
<button ion-button icon-left clear small block>
<button ion-button icon-left clear small block (click)="repost(post.id, post.you_reposted)">
<ion-icon name="repeat"></ion-icon>
<div *ngIf="post.counts.reposts > 0">{{ post.counts.reposts }}</div>
</button>
</ion-col>
<ion-col>
<button ion-button icon-left clear small block>
<ion-icon name="text"></ion-icon>
<ion-icon name="chatboxes"></ion-icon>
<div *ngIf="post.counts.replies > 0">{{ post.counts.replies }}</div>
</button>
</ion-col>
<ion-col>
<button ion-button icon-left clear small block>
<ion-icon name="more"></ion-icon>
</button>
</ion-col>
</ion-row>
</ion-card>
</ion-list>
<ion-fab right bottom>
<button ion-fab>
<ion-icon name="add"></ion-icon>
</button>
</ion-fab>
</ion-content>

View file

@ -58,4 +58,49 @@ export class StreamPage {
this.navCtrl.push(PostDetailsPage, {post: postData});
}
bookmark(postid, bookmarked) {
if (bookmarked) {
pnut.deleteBookmark(postid).then(res => {
console.log(res);
this.updatePost(res.data);
}).catch(err => {
console.log(err);
});
} else {
pnut.bookmark(postid).then(res => {
console.log(res);
this.updatePost(res.data);
}).catch(err => {
console.log(err);
});
}
}
repost(postid, reposted) {
if (reposted) {
pnut.deleteRepost(postid).then(res => {
console.log(res);
this.updatePost(res.data);
}).catch(err => {
console.log(err);
});
} else {
pnut.repost(postid).then(res => {
console.log(res);
this.updatePost(res.data);
}).catch(err => {
console.log(err);
});
}
}
updatePost(postData) {
for (var i = 0; i < this.posts.length; i++) {
if (this.posts[i]['id'] === postData.id) {
this.posts[i] = postData;
break;
}
}
}
}