search function for show editing
This commit is contained in:
16
src/app/services/filter.helper.ts
Normal file
16
src/app/services/filter.helper.ts
Normal 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, '');
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user