Family members emails added

This commit is contained in:
jubitjohn 2023-06-09 11:40:37 +05:30
parent 9fd136c02e
commit 78faf2fae0

View file

@ -10,6 +10,7 @@ import { handleSharingErrors } from 'utils/error/ui';
import { getData, LS_KEYS } from 'utils/storage/localStorage'; import { getData, LS_KEYS } from 'utils/storage/localStorage';
import { CollectionShareSharees } from './sharees'; import { CollectionShareSharees } from './sharees';
import { getLocalCollections } from 'services/collectionService'; import { getLocalCollections } from 'services/collectionService';
import { getLocalFamilyData } from 'utils/user/family';
export default function EmailShare({ collection }) { export default function EmailShare({ collection }) {
const galleryContext = useContext(GalleryContext); const galleryContext = useContext(GalleryContext);
@ -20,6 +21,7 @@ export default function EmailShare({ collection }) {
const getUpdatedOptionsList = async () => { const getUpdatedOptionsList = async () => {
const ownerUser: User = getData(LS_KEYS.USER); const ownerUser: User = getData(LS_KEYS.USER);
const collection_list = getLocalCollections(); const collection_list = getLocalCollections();
const family_list = getLocalFamilyData();
const result = await collection_list; const result = await collection_list;
const emails = result.flatMap((item) => { const emails = result.flatMap((item) => {
const shareeEmails = item.sharees.map((sharee) => sharee.email); const shareeEmails = item.sharees.map((sharee) => sharee.email);
@ -30,6 +32,14 @@ export default function EmailShare({ collection }) {
} }
}); });
// adding family members
if (family_list) {
const family = family_list.members.map(
(member) => member.email
);
emails.push(...family);
}
updatedList = Array.from(new Set(emails)); updatedList = Array.from(new Set(emails));
const shareeEmailsCollection = collection.sharees.map( const shareeEmailsCollection = collection.sharees.map(