import { IonBackButton, IonContent, IonHeader, IonIcon, IonPage, IonTitle, IonToolbar, useIonViewWillEnter, } from "@ionic/react"; import { chevronForward } from "ionicons/icons"; import { useState } from "react"; import { ChatStore, ContactStore } from "../store"; import { getChats, getContacts } from "../store/Selectors"; import "./Starred.scss"; const Starred = () => { const contacts = ContactStore.useState(getContacts); const chats = ChatStore.useState(getChats); const [starredMessages, setStarredMessages] = useState(false); useIonViewWillEnter(() => { var tempChats = [...chats]; var starred = []; tempChats.forEach((tempChat) => { tempChat.chats.forEach((chat) => { if (chat.starred) { starred.push({ contact_id: tempChat.contact_id, ...chat, }); } }); }); setStarredMessages(starred); }); return ( Starred Messages {starredMessages && starredMessages.map((starredMessage) => { const { id, contact_id, date, preview, received } = starredMessage; const contact = contacts.filter((c) => c.id === contact_id)[0]; return (
starred avatar

{contact.name}

{date}

{preview}

); })} {starredMessages.length < 1 && (
no starred

No Starred Messages

Tap and hold on any message to star it, so you can easily find it later.

)}
); }; export default Starred;