Skip to content

Commit

Permalink
fix: history details
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmanos committed Jan 14, 2025
1 parent 91c6a11 commit 08acb5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
13 changes: 1 addition & 12 deletions src/components/History/HistoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useScreenType from '../../hooks/useScreenType';
import { formatDate } from '../../functions/DateFormat';
import { H3 } from '../Shared/Heading';
import HistoryDetailPopup from '../Popups/HistoryDetailPopup';
import { fromBase64 } from '../../util';
import { extractPresentations } from '../../pages/History/HistoryDetail';

const HistoryList = ({ credentialId = null, history, title = '', limit = null }) => {

Expand All @@ -22,17 +22,6 @@ const HistoryList = ({ credentialId = null, history, title = '', limit = null })
}, [history, credentialId, limit]);

const handleHistoryItemClick = async (item) => {
const extractPresentations = (item) => {
if (item.presentation.startsWith("b64:") && (new TextDecoder().decode(fromBase64(item.presentation.replace("b64:", "")))).includes("[")) {
return JSON.parse(new TextDecoder().decode(fromBase64(item.presentation.replace("b64:", ""))));
}
else if (item.presentation.startsWith("b64:")) {
return [ new TextDecoder().decode(fromBase64(item.presentation.replace("b64:", ""))) ];
}
else {
return [ item.presentation ];
}
}
setMatchingCredentials(extractPresentations(item));
if (screenType === 'mobile') {
navigate(`/history/${item.id}`);
Expand Down
14 changes: 13 additions & 1 deletion src/pages/History/HistoryDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ import useFetchPresentations from '../../hooks/useFetchPresentations';
import HistoryDetailContent from '../../components/History/HistoryDetailContent';
import { H1 } from '../../components/Shared/Heading';

export const extractPresentations = (item) => {
if (item.presentation.startsWith("b64:") && (new TextDecoder().decode(fromBase64(item.presentation.replace("b64:", "")))).includes("[")) {
return JSON.parse(new TextDecoder().decode(fromBase64(item.presentation.replace("b64:", ""))));
}
else if (item.presentation.startsWith("b64:")) {
return [ new TextDecoder().decode(fromBase64(item.presentation.replace("b64:", ""))) ];
}
else {
return [ item.presentation ];
}
}

const HistoryDetail = () => {
const { historyId } = useParams();
const { api } = useContext(SessionContext);
Expand All @@ -29,7 +41,7 @@ const HistoryDetail = () => {

useEffect(() => {
if (history.length > 0) {
setMatchingCredentials(history[0].startsWith("b64:") ? JSON.parse(new TextDecoder().decode(fromBase64(history[0].replace("b64:", "")))) : [ history[0] ] );
setMatchingCredentials(extractPresentations(history[0]));
}
}, [history]);

Expand Down

0 comments on commit 08acb5c

Please sign in to comment.