diff --git a/Core/FeedEngine.cs b/Core/FeedEngine.cs
index 4f75d68..1b732bd 100644
--- a/Core/FeedEngine.cs
+++ b/Core/FeedEngine.cs
@@ -60,7 +60,7 @@ namespace LiveGameFeed.Core
FeedViewModel _feed = new FeedViewModel()
{
MatchId = match.Id,
- Description = points + " points for " + (updateHost == true ? match.Host : match.Guest + "!"),
+ Description = points + " points for " + (updateHost == true ? match.Host : match.Guest) + "!",
CreatedAt = DateTime.Now
};
using (var client = new HttpClient())
diff --git a/app/home/home.component.html b/app/home/home.component.html
index 909b52a..a622517 100644
--- a/app/home/home.component.html
+++ b/app/home/home.component.html
@@ -1,6 +1,6 @@
-
+
diff --git a/app/home/home.component.ts b/app/home/home.component.ts
index 3eb0fe6..8edd94a 100644
--- a/app/home/home.component.ts
+++ b/app/home/home.component.ts
@@ -73,4 +73,11 @@ export class HomeComponent implements OnInit {
console.log(error);
});
}
+
+ updateSubscription(subscription: any) {
+ if(subscription.subscribe === true)
+ this.feedService.subscribeToFeed(subscription.matchId);
+ else
+ this.feedService.unsubscribeFromFeed(subscription.matchId);
+ }
}
\ No newline at end of file
diff --git a/app/shared/components/match.component.html b/app/shared/components/match.component.html
index 1c4ba0f..48fbcbd 100644
--- a/app/shared/components/match.component.html
+++ b/app/shared/components/match.component.html
@@ -19,10 +19,10 @@
{{match.Type}}
|
- |
diff --git a/app/shared/components/match.component.ts b/app/shared/components/match.component.ts
index 345625a..124d93b 100644
--- a/app/shared/components/match.component.ts
+++ b/app/shared/components/match.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, Input } from '@angular/core';
+import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { ChatMessage, Match } from '../interfaces';
import { FeedService } from '../services/feed.service';
@@ -11,32 +11,43 @@ import { DataService } from '../services/data.service';
export class MatchComponent implements OnInit {
@Input() match: Match;
+ @Output() updateSubscription = new EventEmitter();
subscribed: boolean;
chatMessage: string = '';
- constructor(private feedService: FeedService,
- private dataService: DataService) { }
+ constructor(private dataService: DataService) { }
- ngOnInit() { }
+ ngOnInit() { }
subscribe() {
console.log(this.match.Id);
this.subscribed = true;
- this.feedService.subscribeToFeed(this.match.Id);
+ //this.feedService.subscribeToFeed(this.match.Id);
}
unsubscribe() {
this.subscribed = false;
- this.feedService.unsubscribeToFeed(this.match.Id);
+ //this.feedService.unsubscribeToFeed(this.match.Id);
+ }
+
+ setSubscription(val: boolean) {
+ this.subscribed = val;
+ let subscription =
+ {
+ subscribe: val,
+ matchId: this.match.Id
+ }
+
+ this.updateSubscription.emit(subscription);
}
addChatMessage() {
let self = this;
- let messageToSend: ChatMessage = {
- MatchId : self.match.Id,
- Text : self.chatMessage,
- CreatedAt : new Date(Date.now())
- };
+ let messageToSend: ChatMessage = {
+ MatchId: self.match.Id,
+ Text: self.chatMessage,
+ CreatedAt: new Date(Date.now())
+ };
this.dataService.addChatMessage(messageToSend)
.subscribe(() => {
diff --git a/app/shared/services/feed.service.ts b/app/shared/services/feed.service.ts
index 908b339..8761e0a 100644
--- a/app/shared/services/feed.service.ts
+++ b/app/shared/services/feed.service.ts
@@ -131,7 +131,7 @@ export class FeedService {
this.server.subscribe(matchId);
}
- public unsubscribeToFeed(matchId: number) {
+ public unsubscribeFromFeed(matchId: number) {
this.server.unsubscribe(matchId);
}
}
\ No newline at end of file