prevent favorite items from being unfavorited.

This commit is contained in:
ammarahm-ed
2020-03-17 15:30:32 +05:00
parent a77da3cca9
commit 0ccfdb7c9b

View File

@@ -15,8 +15,7 @@ import {ACTIONS} from '../../provider/actions';
import {w, ToastEvent, db} from '../../utils/utils';
import {eSendEvent} from '../../services/eventManager';
import {eOpenMoveNoteDialog, eOpenSimpleDialog} from '../../services/events';
import {TEMPLATE_DELETE} from '../DialogManager';
import {TEMPLATE_DELETE} from '../DialogManager/templates';
export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
SafeAreaView,
@@ -128,10 +127,10 @@ export const SelectionHeader = ({navigation}) => {
let unFavCount = 0;
if (selectedItemsList.length > 0) {
selectedItemsList.forEach(async item => {
if (item.favorite) {
if (!item.favorite) {
favCount += 1;
} else {
unFavCount += 1;
return;
}
await db.notes.note(item.id).favorite();
dispatch({type: ACTIONS.NOTES});
@@ -143,10 +142,7 @@ export const SelectionHeader = ({navigation}) => {
dispatch({type: ACTIONS.CLEAR_SELECTION});
ToastEvent.show(
favCount +
' notes added to favorites &' +
unFavCount +
'removed',
favCount + ' notes added to favorites',
'success',
);
}