}
size="large" spellCheck="false" onChange={(e) => actions.onFilter(e.target.value)} />
diff --git a/net/web/src/session/cards/Cards.styled.js b/net/web/src/session/cards/Cards.styled.js
index b7fc62cb..19abd257 100644
--- a/net/web/src/session/cards/Cards.styled.js
+++ b/net/web/src/session/cards/Cards.styled.js
@@ -19,6 +19,25 @@ export const CardsWrapper = styled.div`
display: flex;
flex-direction: row;
+ .sorted {
+ color: ${Colors.enabled};
+ font-size: 18px;
+ padding-right: 8px;
+ display: flex;
+ align-items: center;
+ cursor: pointer;
+ }
+
+ .unsorted {
+ color: ${Colors.disabled};
+ font-size: 18px;
+ padding-right: 8px;
+ display: flex;
+ align-items: center;
+ cursor: pointer;
+ }
+
+
.filter {
border: 1px solid ${Colors.divider};
background-color: ${Colors.white};
@@ -70,7 +89,7 @@ export const CardsWrapper = styled.div`
padding-left: 16px;
padding-right: 16px;
border-radius: 4px;
- font-size: 18px;
+ font-size: 14px;
cursor: pointer;
height: 100%;
diff --git a/net/web/src/session/cards/cardItem/CardItem.jsx b/net/web/src/session/cards/cardItem/CardItem.jsx
index ad322efb..c4f34e62 100644
--- a/net/web/src/session/cards/cardItem/CardItem.jsx
+++ b/net/web/src/session/cards/cardItem/CardItem.jsx
@@ -1,3 +1,3 @@
-export function CardItem() {
- return
CARD ITEM
+export function CardItem({ item }) {
+ return
{ item?.data?.cardProfile?.name }
}
diff --git a/net/web/src/session/cards/useCards.hook.js b/net/web/src/session/cards/useCards.hook.js
index 11b9881d..144d816d 100644
--- a/net/web/src/session/cards/useCards.hook.js
+++ b/net/web/src/session/cards/useCards.hook.js
@@ -7,6 +7,7 @@ export function useCards() {
const [filter, setFilter] = useState(null);
const [state, setState] = useState({
+ sorted: false,
display: null,
cards: [],
busy: false }
@@ -23,10 +24,44 @@ export function useCards() {
onFilter: (value) => {
setFilter(value.toUpperCase());
},
+ setSort: (value) => {
+ updateState({ sorted: value });
+ },
};
useEffect(() => {
- }, [card]);
+ const contacts = Array.from(card.state.cards.values());
+
+ let filtered = contacts.filter((contact) => {
+ if (!filter) {
+ return true;
+ }
+ if (!contact?.data?.cardProfile?.name) {
+ return false;
+ }
+ return contact.data.cardProfile.name.toUpperCase().includes(filter);
+ });
+
+ if (state.sorted) {
+ filtered.sort((a, b) => {
+ if (a?.data?.cardProfile?.name > b?.data?.cardProfile?.name) {
+ return -1;
+ }
+ return 1;
+ });
+ }
+ else {
+ filtered.sort((a, b) => {
+ if (a?.data?.cardDetails?.statusUpdated > b?.data?.cardDetails?.statusUpdated) {
+ return -1;
+ }
+ return 1;
+ });
+ }
+
+ updateState({ cards: filtered });
+
+ }, [card, filter, state.sorted]);
useEffect(() => {
updateState({ display: viewport.state.display });
diff --git a/net/web/src/session/channels/Channels.styled.js b/net/web/src/session/channels/Channels.styled.js
index 8ed78b5a..2649e526 100644
--- a/net/web/src/session/channels/Channels.styled.js
+++ b/net/web/src/session/channels/Channels.styled.js
@@ -64,7 +64,7 @@ export const ChannelsWrapper = styled.div`
padding-left: 16px;
padding-right: 16px;
border-radius: 4px;
- font-size: 18px;
+ font-size: 14px;
cursor: pointer;
height: 100%;
diff --git a/net/web/src/session/identity/Identity.jsx b/net/web/src/session/identity/Identity.jsx
index 990f4560..9765a9ca 100644
--- a/net/web/src/session/identity/Identity.jsx
+++ b/net/web/src/session/identity/Identity.jsx
@@ -1,10 +1,10 @@
import { Dropdown, Menu, Tooltip } from 'antd';
import { Logo } from 'logo/Logo';
-import { IdentityWrapper } from './Identity.styled';
+import { IdentityWrapper, ErrorNotice, InfoNotice } from './Identity.styled';
import { useIdentity } from './useIdentity.hook';
-import { ExclamationCircleOutlined, DownOutlined } from '@ant-design/icons';
+import { InfoCircleOutlined, ExclamationCircleOutlined, DownOutlined } from '@ant-design/icons';
-export function Identity({ openCards }) {
+export function Identity({ openCards, cardUpdated }) {
const { state, actions } = useIdentity();
@@ -31,15 +31,25 @@ export function Identity({ openCards }) {
{state.name}
-
+
{ state.disconnected && (
-
+
+
+
)}
{state.handle}
-
+
+ { cardUpdated && (
+
+
+
+
+
+ )}
+
diff --git a/net/web/src/session/identity/Identity.styled.js b/net/web/src/session/identity/Identity.styled.js
index 6d8b2a8b..8848e0d3 100644
--- a/net/web/src/session/identity/Identity.styled.js
+++ b/net/web/src/session/identity/Identity.styled.js
@@ -47,11 +47,21 @@ export const IdentityWrapper = styled.div`
align-items: center;
font-weight: bold;
- .alert {
- width: 24px;
- color: ${Colors.alert};
+ .notice {
+ width: 32px;
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
}
}
}
`;
+export const ErrorNotice = styled.div`
+ color: ${Colors.alert};
+`
+
+export const InfoNotice = styled.div`
+ color: ${Colors.primary};
+`
+
diff --git a/net/web/src/session/useSession.hook.js b/net/web/src/session/useSession.hook.js
index 8e70e62d..9130bcf7 100644
--- a/net/web/src/session/useSession.hook.js
+++ b/net/web/src/session/useSession.hook.js
@@ -1,8 +1,11 @@
-import { useState, useEffect } from 'react';
+import { useContext, useState, useEffect, useRef } from 'react';
+import { CardContext } from 'context/CardContext';
+import { StoreContext } from 'context/StoreContext';
export function useSession() {
const [state, setState] = useState({
+ cardUpdated: false,
conversation: false,
details: false,
cards: false,
@@ -10,18 +13,39 @@ export function useSession() {
profile: false,
});
+ const card = useContext(CardContext);
+ const store = useContext(StoreContext);
+
+ const storeStatus = useRef(null);
+ const cardStatus = useRef(null);
+
const updateState = (value) => {
setState((s) => ({ ...s, ...value }));
}
useEffect(() => {
- setTimeout(() => {
- updateState({ cards: true });
- }, 1000);
- setTimeout(() => {
- updateState({ contact: true });
- }, 2000);
- }, []);
+ const contacts = Array.from(card.state.cards.values());
+
+ let updated;
+ contacts.forEach(contact => {
+ if (!updated || updated < contact?.data?.cardDetail?.statusUpdated) {
+ updated = contact?.data?.cardDetail?.statusUpdated;
+ }
+ });
+
+ if (state.cards) {
+ cardStatus.current = updated;
+ storeStatus.current = updated;
+ store.actions.setValue('cards:updated', updated);
+ }
+
+ updateState({ cardUpdated: cardStatus.current > storeStatus.current });
+ }, [card]);
+
+ useEffect(() => {
+ storeStatus.current = store.actions.getValue('cards:updated');
+ updateState({ cardUpdated: cardStatus.current > storeStatus.current });
+ }, [store]);
const actions = {
closeDetails: () => {