search function for show editing

This commit is contained in:
2020-04-21 18:43:08 +02:00
committed by smuddy
parent 5695640fe4
commit c526f127e8
10 changed files with 73 additions and 35 deletions

View File

@@ -0,0 +1,16 @@
import {Song} from '../modules/songs/services/song';
export function filterSong(song: Song, filterValue: string): boolean {
if (!filterValue) {
return true;
}
const textMatch = song.text && normalize(song.text).indexOf(normalize(filterValue)) !== -1;
const titleMatch = song.title && normalize(song.title).indexOf(normalize(filterValue)) !== -1;
return textMatch || titleMatch;
}
function normalize(input: string): string {
return input.toLowerCase().replace(/\s/g, '');
}

View File

@@ -22,6 +22,10 @@ export class UserService {
return this._user$.pipe(filter(_ => !!_));
}
public getUserbyId$(userId: string): Observable<User> {
return this.db.doc$<User>('user/' + userId);
}
public async update$(uid: string, data: Partial<User>): Promise<void> {
await this.db.doc<User>('user/' + uid).update(data);
}