Skip to content
This repository has been archived by the owner on Mar 26, 2022. It is now read-only.

Commit

Permalink
Added some dummy data
Browse files Browse the repository at this point in the history
  • Loading branch information
Migarve55 committed Feb 27, 2019
1 parent 25ecfa5 commit a7a7872
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/app/message/message.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export class MessageComponent implements OnInit {
isOwnMessage: boolean;
ownEmail: string;

constructor() {
/* authService.authUser().subscribe(user => {
this.userName = user.userName;
this.isOwnMessage = true;
}); */
constructor(private chatService : ChatService) {
chatService.getUser().subscribe(user => {
this.userName = user.username;
this.isOwnMessage = user.username === "Miguel";
});
}

ngOnInit(chatMessage = this.chatMessage) {
Expand Down
6 changes: 6 additions & 0 deletions src/app/models/chat-message.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export class ChatMessage {

constructor(userName, message) {
this.userName = userName;
this.message = message;
}

$key?: string;
userName?: string;
message?: string;
Expand Down
5 changes: 5 additions & 0 deletions src/app/models/user.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export class User {

constructor(username) {
this.username = username;
}

uid?: string;
username?: string;
status?: string;
Expand Down
17 changes: 10 additions & 7 deletions src/app/services/chat.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Observable, of } from 'rxjs';

import { ChatMessage } from '../models/chat-message.model';
import { RdfService } from './rdf.service';
Expand All @@ -15,25 +15,28 @@ export class ChatService {
}

getUser() {
return this.getUsers().subscribe(users => {
return users[0];
});
return of(new User("Miguel"));
}

getUsers() : Observable<User[]> {
var users = new Array<User>();
return new Observable();
users.push(new User("Fulanito"));
users.push(new User("Menganito"));
users.push(new User("Adolfito"));
return of(users);
}

sendMessage(msg: string) {
const timestamp = this.getTimeStamp();
this.chatMessages = this.getMessages();
this.chatMessages.toPromise();
}

getMessages(): Observable<ChatMessage[]> {
var messages = new Array<ChatMessage>();
return new Observable();
messages.push(new ChatMessage("Miguel", "Hola"));
messages.push(new ChatMessage("Adolfito", "Que tal?"));
messages.push(new ChatMessage("Miguel", "Bien"));
return of(messages);
}

getTimeStamp() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/user-item/user-item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<span class="status" [ngClass]=(user.status)>
</span>
<span class="userName">
{{user.displayName}}
{{user.username}}
</span>
</div>

0 comments on commit a7a7872

Please sign in to comment.