diff --git a/env.template b/env.template index bbf2be67..73ac46a5 100644 --- a/env.template +++ b/env.template @@ -1,5 +1,5 @@ VITE_SOLID_IDENTITY_PROVIDER="http://localhost:3000/" VITE_SOLID_POD_SERVER="http://localhost:3000/" VITE_SUGGESTED_OIDC_OPTIONS="http://localhost:3000/, https://opencommons.net/, https://solidcommunity.net/, https://login.inrupt.com/, https://inrupt.net/" -VITE_OIDC_WEBIDS = '{"http://localhost:3000/": "http://localhost:3000/user/profile/card#me", "https://opencommons.net/": "http://opencommons.net/user/profile/card#me", "https://solidcommunity.net/": "https://user.solidcommunity.net/profile/card#me", "https://login.inrupt.com/": "https://id.inrupt.com/user", "https://inrupt.net/": "https://id.inrupt.com/user"}' +VITE_OIDC_WEBIDS = '{"http://localhost:3000/": "http://localhost:3000/user/profile/card#me", "https://opencommons.net/": "https://opencommons.net/user/profile/card#me", "https://solidcommunity.net/": "https://user.solidcommunity.net/profile/card#me", "https://login.inrupt.com/": "https://id.inrupt.com/user", "https://inrupt.net/": "https://id.inrupt.com/user"}' VITE_CLIENT_ID_DOC="http://localhost:3000/clientAppId.json" diff --git a/src/components/Modals/NewMessageModal.jsx b/src/components/Modals/NewMessageModal.jsx index efd1df10..694c7084 100644 --- a/src/components/Modals/NewMessageModal.jsx +++ b/src/components/Modals/NewMessageModal.jsx @@ -1,5 +1,6 @@ // React Imports import React, { useContext, useEffect, useState } from 'react'; +import { useLocation } from 'react-router-dom'; // Inrupt Library Imports import { useMessageList, useNotification, useSession, useContactsList } from '@hooks'; // Material UI Imports @@ -46,6 +47,7 @@ const NewMessageModal = ({ showModal, setShowModal, oldMessage = '', toField = ' const { podUrl } = useContext(SignedInUserContext); const { addNotification } = useNotification(); const [originalMessage, setOriginalMessage] = useState(oldMessage.message); + const location = useLocation(); const [message, setMessage] = useState({ recipientPodUrl: @@ -111,7 +113,7 @@ const NewMessageModal = ({ showModal, setShowModal, oldMessage = '', toField = ' await sendMessageTTL(session, messageWithTrimmedInputs, podUrl); setMessage({ - recipientPodUrl: '', + recipientPodUrl: location.pathname === '/contacts' ? toField : '', title: '', message: '' }); diff --git a/test/components/Messages/MessagePreview.test.jsx b/test/components/Messages/MessagePreview.test.jsx index 7e7450ab..68b1943e 100644 --- a/test/components/Messages/MessagePreview.test.jsx +++ b/test/components/Messages/MessagePreview.test.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { render, cleanup } from '@testing-library/react'; -import { describe, expect, it, afterEach } from 'vitest'; +import { describe, expect, it, afterEach, vi } from 'vitest'; import { MessagePreview } from '@components/Messages'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import createMatchMedia from '../../helpers/createMatchMedia'; @@ -19,6 +19,16 @@ const MockMessagePreview = ({ folderType = 'Inbox' }) => ( ); +vi.mock('react-router-dom', async () => { + const actual = vi.importActual('react-router-dom'); + return { + ...actual, + useLocation: vi.fn().mockReturnValue({ + pathname: '/contacts' + }) + }; +}); + describe('Grid sizes', () => { afterEach(() => { cleanup(); diff --git a/test/components/Modals/NewMessageModal.test.jsx b/test/components/Modals/NewMessageModal.test.jsx index 7210aaff..91d027ec 100644 --- a/test/components/Modals/NewMessageModal.test.jsx +++ b/test/components/Modals/NewMessageModal.test.jsx @@ -16,6 +16,16 @@ const MockNewMessageModal = () => ( ); +vi.mock('react-router-dom', async () => { + const actual = vi.importActual('react-router-dom'); + return { + ...actual, + useLocation: vi.fn().mockReturnValue({ + pathname: '/contacts' + }) + }; +}); + it('renders button group flex-direction as row default', () => { const { getByRole } = render(); const cancelButton = getByRole('button', { name: 'Cancel' });