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