书签按钮(左侧的按钮)将报纸添加到用户集合中(如第二幅图所示),但是在获取报纸时我没有进行检查。我该如何更改按钮颜色?
这是我获取报纸以及将其保存到用户收藏夹中的方式:
getDefaultNewspapers() {
this.newspapers$ = this.likes$.pipe(
switchMap(likes =>
this.angularFirestore
.collection<NewspaperModel>("newspapers", ref =>
ref.where("likes", ">=", likes).orderBy("likes", "desc") // forget about this filter
)
// .valueChanges()
.snapshotChanges() // necessary for metadata like IDs
.map(newspapers => {
return newspapers.map(newspaper => {
const $id = newspaper.payload.doc.id;
const data = newspaper.payload.doc.data() as NewspaperModel;
return { $id, ...data };
});
})
)
);
}
addRemoveFavourite(newspaperId: string) {
this.angularFirestore
.collection("users")
.doc(this.afAuth.auth.currentUser.uid)
.update({
["myNews." + newspaperId]: {
favourite: false,
visits: 0
}
});
}