[U] add user to story model. user service minor fixes
This commit is contained in:
parent
99439ee7f6
commit
6880d9c033
2 changed files with 8 additions and 3 deletions
|
|
@ -1,7 +1,10 @@
|
||||||
|
import { User } from './user';
|
||||||
|
|
||||||
export class Story {
|
export class Story {
|
||||||
id: string;
|
id: string;
|
||||||
standup_id: number;
|
standup_id: number;
|
||||||
user_id: string
|
user_id: string;
|
||||||
|
user?: User;
|
||||||
src: string;
|
src: string;
|
||||||
created_at: string | Date;
|
created_at: string | Date;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,12 +79,12 @@ export class UserService {
|
||||||
* Retrieve users from local store.
|
* Retrieve users from local store.
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
getOne(id: number) {
|
getOne(id: string) {
|
||||||
if (this.userMap[id]) {
|
if (this.userMap[id]) {
|
||||||
return of(this.userMap[id]);
|
return of(this.userMap[id]);
|
||||||
} else {
|
} else {
|
||||||
const subject: Subject<User> = new Subject();
|
const subject: Subject<User> = new Subject();
|
||||||
this.supa.client.from<User>('user').select('id, name, description')
|
this.supa.client.from<User>('user').select()
|
||||||
.filter(<never>'id', 'eq', id)
|
.filter(<never>'id', 'eq', id)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.updateStore([data.body[0]]);
|
this.updateStore([data.body[0]]);
|
||||||
|
|
@ -109,6 +109,7 @@ export class UserService {
|
||||||
.match({ id: user.id })
|
.match({ id: user.id })
|
||||||
.then(data => {
|
.then(data => {
|
||||||
subject.next(data.body[0]);
|
subject.next(data.body[0]);
|
||||||
|
this.updateStore([data.body[0]]);
|
||||||
subject.complete();
|
subject.complete();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|
@ -147,6 +148,7 @@ export class UserService {
|
||||||
this.supa.client.from<User>('user').insert(user)
|
this.supa.client.from<User>('user').insert(user)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
subject.next(data.body[0]);
|
subject.next(data.body[0]);
|
||||||
|
this.updateStore([data.body[0]]);
|
||||||
subject.complete();
|
subject.complete();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue