diff --git a/src/app/common/services/api/client.ts b/src/app/common/services/api/client.ts
index 86b1896e..83b9fbab 100644
--- a/src/app/common/services/api/client.ts
+++ b/src/app/common/services/api/client.ts
@@ -8,6 +8,8 @@ export class Client {
base : string = "https://edge.minds.com/";
oauth2;
+ storage = new Storage();
+
constructor(public http : Http){
this.oauth2 = new OAuth2(http);
}
@@ -34,7 +36,9 @@ export class Client {
});*/
var Objecti : any = Object;
- return Objecti.assign(options, {});
+ return Objecti.assign(options, {
+ access_token: this.storage.get('access_token')
+ });
}
/**
@@ -102,6 +106,7 @@ export class Client {
*/
put(endpoint : string, data : Object = {}, options: Object = {}){
var self = this;
+ endpoint += "?" + this.buildParams({});
return new Promise((resolve, reject) => {
self.http.put(
self.base + endpoint,
@@ -133,6 +138,7 @@ export class Client {
*/
delete(endpoint : string, data : Object = {}, options: Object = {}){
var self = this;
+ endpoint += "?" + this.buildParams({});
return new Promise((resolve, reject) => {
self.http.delete(
self.base + endpoint,
diff --git a/src/app/modules/buttons/remind.component.ts b/src/app/modules/buttons/remind.component.ts
index 4c7d1917..85a1df88 100644
--- a/src/app/modules/buttons/remind.component.ts
+++ b/src/app/modules/buttons/remind.component.ts
@@ -18,7 +18,6 @@ export class RemindButtonComponent {
entity = {
'guid': null,
'owner_guid': null,
- 'thumbs:up:user_guids': []
};
constructor(public client : Client) {
@@ -28,8 +27,6 @@ export class RemindButtonComponent {
if(!value)
return;
this.entity = value;
- if(!this.entity['thumbs:up:user_guids'])
- this.entity['thumbs:up:user_guids'] = [];
}
diff --git a/src/app/modules/buttons/thumbsdown.component.ts b/src/app/modules/buttons/thumbsdown.component.ts
index b708e1c1..4ef9c52a 100644
--- a/src/app/modules/buttons/thumbsdown.component.ts
+++ b/src/app/modules/buttons/thumbsdown.component.ts
@@ -1,14 +1,18 @@
import { Component, ChangeDetectionStrategy, Input } from '@angular/core';
import { Client } from '../../common/services/api/client';
+import { Storage } from '../../common/services/storage';
@Component({
moduleId: 'module.id',
selector: 'minds-button-thumbs-down',
changeDetection: ChangeDetectionStrategy.OnPush,
+ host: {
+ '(click)': 'thumb()'
+ },
template: `
-
+
`,
//styleUrls: ['buttons.css']
})
@@ -18,9 +22,11 @@ export class ThumbsDownComponent {
entity = {
'guid': null,
'owner_guid': null,
- 'thumbs:up:user_guids': []
+ 'thumbs:down:user_guids': []
};
+ storage = new Storage();
+
constructor(public client : Client) {
}
@@ -28,8 +34,39 @@ export class ThumbsDownComponent {
if(!value)
return;
this.entity = value;
- if(!this.entity['thumbs:up:user_guids'])
- this.entity['thumbs:up:user_guids'] = [];
+ if(!this.entity['thumbs:down:user_guids'])
+ this.entity['thumbs:down:user_guids'] = [];
+ }
+
+ thumb(){
+ var self = this;
+
+ this.client.put('api/v1/thumbs/' + this.entity.guid + '/down', {});
+ if(!this.has()){
+ //this.entity['thumbs:up:user_guids'].push(this.session.getLoggedInUser().guid);
+ this.entity['thumbs:down:user_guids'] = [ this.storage.get('user_guid') ];
+ this.entity['thumbs:down:count']++;
+ if ( this.storage.get('user_guid') != this.entity.owner_guid) {
+ //self.wallet.increment();
+ }
+ } else {
+ for(let key in this.entity['thumbs:down:user_guids']){
+ if(this.entity['thumbs:down:user_guids'][key] == this.storage.get('user_guid'))
+ delete this.entity['thumbs:down:user_guids'][key];
+ }
+ this.entity['thumbs:down:count']--;
+ if ( this.storage.get('user_guid')!= this.entity.owner_guid) {
+ //self.wallet.decrement();
+ }
+ }
+ }
+
+ has(){
+ for(var guid of this.entity['thumbs:down:user_guids']){
+ if(guid == this.storage.get('user_guid'))
+ return true;
+ }
+ return false;
}
}
diff --git a/src/app/modules/buttons/thumbsup.component.ts b/src/app/modules/buttons/thumbsup.component.ts
index f0964c11..77173ec6 100644
--- a/src/app/modules/buttons/thumbsup.component.ts
+++ b/src/app/modules/buttons/thumbsup.component.ts
@@ -1,14 +1,18 @@
import { Component, ChangeDetectionStrategy, Input } from '@angular/core';
import { Client } from '../../common/services/api/client';
+import { Storage } from '../../common/services/storage';
@Component({
moduleId: 'module.id',
selector: 'minds-button-thumbs-up',
changeDetection: ChangeDetectionStrategy.OnPush,
+ host: {
+ '(click)': 'thumb()'
+ },
template: `
-
+
`,
//styleUrls: [ 'buttons.css' ]
})
@@ -21,6 +25,8 @@ export class ThumbsUpComponent {
'thumbs:up:user_guids': []
};
+ storage = new Storage();
+
constructor(public client : Client) {
}
@@ -35,37 +41,31 @@ export class ThumbsUpComponent {
thumb(){
var self = this;
- /*if(!this.session.isLoggedIn()){
- this.modal.setSubtitle("You need to have a channel to vote").open();
- this.showModal = true;
- return false;
- }
-
- this.client.put('api/v1/thumbs/' + this.object.guid + '/up', {});
+ this.client.put('api/v1/thumbs/' + this.entity.guid + '/up', {});
if(!this.has()){
- //this.object['thumbs:up:user_guids'].push(this.session.getLoggedInUser().guid);
- this.object['thumbs:up:user_guids'] = [this.session.getLoggedInUser().guid];
- this.object['thumbs:up:count']++;
- if (this.session.getLoggedInUser().guid != this.object.owner_guid) {
- self.wallet.increment();
+ //this.entity['thumbs:up:user_guids'].push(this.session.getLoggedInUser().guid);
+ this.entity['thumbs:up:user_guids'] = [ this.storage.get('user_guid') ];
+ this.entity['thumbs:up:count']++;
+ if ( this.storage.get('user_guid') != this.entity.owner_guid) {
+ //self.wallet.increment();
}
} else {
- for(let key in this.object['thumbs:up:user_guids']){
- if(this.object['thumbs:up:user_guids'][key] == this.session.getLoggedInUser().guid)
- delete this.object['thumbs:up:user_guids'][key];
+ for(let key in this.entity['thumbs:up:user_guids']){
+ if(this.entity['thumbs:up:user_guids'][key] == this.storage.get('user_guid'))
+ delete this.entity['thumbs:up:user_guids'][key];
}
- this.object['thumbs:up:count']--;
- if (this.session.getLoggedInUser().guid != this.object.owner_guid) {
- self.wallet.decrement();
+ this.entity['thumbs:up:count']--;
+ if ( this.storage.get('user_guid')!= this.entity.owner_guid) {
+ //self.wallet.decrement();
}
- }*/
+ }
}
has(){
- /*for(var guid of this.entity['thumbs:up:user_guids']){
- //if(guid == this.session.getLoggedInUser().guid)
- // return true;
- }*/
+ for(var guid of this.entity['thumbs:up:user_guids']){
+ if(guid == this.storage.get('user_guid'))
+ return true;
+ }
return false;
}
diff --git a/src/app/modules/newsfeed/activity/activity.component.scss b/src/app/modules/newsfeed/activity/activity.component.scss
index 187ae73e..779ee95c 100644
--- a/src/app/modules/newsfeed/activity/activity.component.scss
+++ b/src/app/modules/newsfeed/activity/activity.component.scss
@@ -10,6 +10,10 @@
color: #333;
text-decoration:none;
}
+
+ span{
+ font-size:11px;
+ }
}
.m-ionic-avatar{
diff --git a/src/app/modules/newsfeed/list.component.html b/src/app/modules/newsfeed/list.component.html
index e3ebaa3e..d04bfbda 100644
--- a/src/app/modules/newsfeed/list.component.html
+++ b/src/app/modules/newsfeed/list.component.html
@@ -1,9 +1,9 @@
-
diff --git a/src/app/modules/newsfeed/list.component.ts b/src/app/modules/newsfeed/list.component.ts
index 11a72d35..57c4361b 100644
--- a/src/app/modules/newsfeed/list.component.ts
+++ b/src/app/modules/newsfeed/list.component.ts
@@ -2,6 +2,8 @@ import { Component, OnInit, OnDestroy, Input, ChangeDetectionStrategy, ChangeDet
import { ChannelComponent } from '../channel/channel.component';
import { Client } from '../../common/services/api/client';
+import { Storage } from '../../common/services/storage';
+
@Component({
moduleId: 'module.id',
@@ -17,6 +19,8 @@ export class NewsfeedList {
offset : string = "";
inProgress : boolean = true;
+ storage = new Storage();
+
components = {
channel: ChannelComponent
}