Skip to content

Commit

Permalink
(feat): support single newsfeed routes
Browse files Browse the repository at this point in the history
  • Loading branch information
markharding committed Nov 29, 2016
1 parent 92e6a20 commit 2f18249
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 16 deletions.
2 changes: 2 additions & 0 deletions app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CacheModule } from './src/common/services/cache/cache.module';
import { AuthModule } from './src/modules/auth/auth.module';
import { TabsModule } from './src/modules/tabs/tabs.module';
import { ChannelModule } from './src/modules/channel/channel.module';
import { NewsfeedModule } from './src/modules/newsfeed/newsfeed.module';
import { NotificationsModule } from './src/modules/notifications/notifications.module';


Expand Down Expand Up @@ -40,6 +41,7 @@ registerElement("VideoPlayer", () => require("nativescript-videoplayer").Video);
AuthModule,
TabsModule,
ChannelModule,
NewsfeedModule,
NotificationsModule,
NativeScriptRouterModule,
NativeScriptRouterModule.forRoot(routes)
Expand Down
2 changes: 2 additions & 0 deletions app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { TabsComponent } from './src/modules/tabs/tabs.component';
import { NewsfeedSingleComponent } from './src/modules/newsfeed/single.component';
import { ChannelComponent } from './src/modules/channel/channel.component';
import { LoginComponent } from './src/modules/auth/login.component';

export const routes = [
{ path: "", redirectTo: "/login", pathMatch: "full", terminal: true },
{ path: "login", component: LoginComponent },
{ path: "tab/:id", component: TabsComponent },
{ path: "newsfeed/:id", component: NewsfeedSingleComponent }
{ path: "channel/:id", component: ChannelComponent }
];
6 changes: 3 additions & 3 deletions app/src/modules/newsfeed/newsfeed.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NativeScriptModule } from "nativescript-angular/platform";

import { Client } from '../../common/services/api/client';
import { NewsfeedList } from './list.component';
import { NewsfeedSingle } from './single';
import { NewsfeedSingleComponent } from './single.component';
import { Activity } from './activity/activity.component';
import { Remind } from './activity/remind.component';

Expand All @@ -29,7 +29,7 @@ import { ImageGarbageCollectDirective } from '../../common/directives/image-garb
]*/
imports: [ NativeScriptModule, NativeScriptRouterModule ],
providers: [ Client ],
declarations: [ NewsfeedList, NewsfeedSingle, Activity, Remind, ImageCachePipe, ImageGarbageCollectDirective ],
exports: [ NewsfeedList, NewsfeedSingle, Activity, Remind ]
declarations: [ NewsfeedList, NewsfeedSingleComponent, Activity, Remind, ImageCachePipe, ImageGarbageCollectDirective ],
exports: [ NewsfeedList, NewsfeedSingleComponent, Activity, Remind ]
})
export class NewsfeedModule { }
40 changes: 40 additions & 0 deletions app/src/modules/newsfeed/single.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Client } from '../../common/services/api/client';


@Component({
selector: 'newsfeed-single',
template: `
<StackLayout>
<activity [entity]="entity" *ngIf="entity"></activity>
</StackLayout>
`
})

export class NewsfeedSingleComponent {

guid : string;
entity;
inProgress : boolean = false;

constructor(private client : Client, private route : ActivatedRoute){}

ngOnInit(){
this.route.params.subscribe((params) => {
this.guid = params['id'];
this.entity = null;
this.load();
});
}

load(){
this.inProgress = true;
this.client.get('api/v1/newsfeed/single/' + this.guid, {})
.then((response : any) => {
this.entity = response.activity;
});
}


}
11 changes: 0 additions & 11 deletions app/src/modules/newsfeed/single.ts

This file was deleted.

30 changes: 29 additions & 1 deletion app/src/modules/notifications/card/card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,37 @@
<!-- subscribed -->
<template ngSwitchCase="friends">
<Label *ngIf="entity.fromObj.subscribed" [text]="'You have a match! ' + entity.fromObj.name + ' subscribed to you'"></Label>
<Label *ngIf="!entity.fromObj.subscribed" [text]="entity.fromObj.name + 'subscribed to you'"></Label>
<Label *ngIf="!entity.fromObj.subscribed" [text]="entity.fromObj.name + ' subscribed to you'"></Label>
</template>

<template ngSwitchCase="group_activity">
<StackLayout [nsRouterLink]="['/newsfeed/:id', { id: entity.entityObj.guid}]">
<Label [text]="entity.fromObj.name + 'posted in ' + entity.params.group.name"></Label>
</StackLayout>
</template>

<!-- up voted content -->
<template ngSwitchCase="like">
<StackLayout *ngIf="entity.entityObj" orientation="horizontal">
<Label [text]="entity.fromObj.name + 'voted up '"></Label>

<StackLayout *ngIf="entity.entityObj.type == 'object'">
<Label *ngIf="entity.entityObj.title" [text]="entity.entityObj.title"></Label>
<Label *ngIf="!entity.entityObj.title" [text]="'your' + entity.entityObj.subtype"></Label>
</StackLayout>
<StackLayout *ngIf="entity.entityObj.type == 'activity'" orientation="horizontal">
<Label [text]="entity.entityObj.title || 'your activity'"></Label>
</StackLayout>

<StackLayout *ngIf="entity.entityObj.type == 'comment'">
<Label text="your comment"></Label>
</StackLayout>
<StackLayout *ngIf="!entity.entityObj">

</StackLayout>

</StackLayout>
</template>

</StackLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/notifications/card/card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class NotificationCard {

@Input('entity') set _entity(entity){
this.entity = entity;
this.cache.set('channel:' + entity.ownerObj.guid, entity.ownerObj, false);
this.cache.set('channel:' + entity.fromObj.guid, entity.fromObj, false);
}

onLoaded(){
Expand Down

0 comments on commit 2f18249

Please sign in to comment.