Skip to content

Commit d157909

Browse files
authored
Merge pull request #941 from dm3-org/develop
Fix query param
2 parents b03d1df + e6241ac commit d157909

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

LICENSE

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
BSD 2-Clause License
22

3-
Copyright (c) 2022,2023, corpus.ventures GmbH
4-
Copyright (c) 2023, dm3.org GmbH
3+
Copyright (c) 2022,2023 corpus.ventures GmbH
4+
Copyright (c) 2023 dm3.org GmbH
5+
Copyright (c) 2024 dm3.org gGmbH
6+
57
All rights reserved.
68

79
Redistribution and use in source and binary forms, with or without

docker/prod/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ services:
107107
REACT_APP_RESOLVER_BACKEND: ${REACT_APP_RESOLVER_BACKEND}
108108
REACT_APP_USER_ENS_SUBDOMAIN: ${REACT_APP_USER_ENS_SUBDOMAIN}
109109
REACT_APP_WALLET_CONNECT_PROJECT_ID: ${REACT_APP_WALLET_CONNECT_PROJECT_ID}
110+
REACT_APP_GENOME_REGISTRY_ADDRESS: ${REACT_APP_GENOME_REGISTRY_ADDRESS}
110111
RESOLVER_ADDR: ${RESOLVER_ADDR}
111112

112113
certbot:

packages/messenger-web/src/Dm3Widget.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const Dm3Widget: React.FC = () => {
2121

2222
// Define the configuration props for the DM3 component
2323
const props: DM3Configuration = {
24-
defaultContact: isMessageToSet() ? messageTo! : 'contact.dm3.eth', // If messageTo is set, use it as the default contact
24+
defaultContact: isMessageToSet ? messageTo! : 'contact.dm3.eth', // If messageTo is set, use it as the default contact
2525
userEnsSubdomain: process.env.REACT_APP_USER_ENS_SUBDOMAIN as string,
2626
addressEnsSubdomain: process.env.REACT_APP_ADDR_ENS_SUBDOMAIN as string,
2727
resolverBackendUrl: process.env.REACT_APP_RESOLVER_BACKEND as string,
@@ -38,7 +38,7 @@ const Dm3Widget: React.FC = () => {
3838
genomeRegistryAddress: process.env
3939
.REACT_APP_GENOME_REGISTRY_ADDRESS as string,
4040
showAlways: true,
41-
showContacts: !isMessageToSet(), // Show all contacts or only the default based on the message destination
41+
showContacts: !isMessageToSet, // Show all contacts or only the default based on the message destination
4242
signInImage: signInImagePath, // Dynamic image path based on the current week
4343
};
4444

packages/messenger-web/src/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const Header: React.FC = () => {
2020
</a>
2121

2222
{/* Conditionally render the message tag if the messageTo parameter is set */}
23-
{isMessageToSet() && (
23+
{isMessageToSet && (
2424
<div className="message-tag">
2525
<span>Send message to:</span>
2626
<strong>{messageTo}</strong>

packages/messenger-web/src/parameter/messageto/MessageToContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createContext, useContext } from 'react';
33
// Define a type for the context value
44
interface MessageToContextType {
55
messageTo: string | null;
6-
isMessageToSet: () => boolean;
6+
isMessageToSet: boolean;
77
}
88

99
// Create the context with an initial undefined value. The actual value is provided by the provider.

packages/messenger-web/src/parameter/messageto/useMessageTo.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { useState, useEffect } from 'react';
1+
import { useState, useEffect, useMemo } from 'react';
22

33
/**
44
* A custom hook for retrieving the 'messageTo' URL parameter value.
55
* It returns the value of 'messageTo' and a function to check if it's set.
66
*/
7-
export const useMessageTo = (): [string | null, () => boolean] => {
7+
export const useMessageTo = (): [string | null, boolean] => {
88
// State to store the value of 'messageTo'
99
const [messageTo, setMessageTo] = useState<string | null>(null);
1010

@@ -19,10 +19,10 @@ export const useMessageTo = (): [string | null, () => boolean] => {
1919
setMessageTo(paramValue);
2020
}, []); // Empty dependency array means this effect runs once on mount
2121

22-
// Function to check if 'messageTo' is set (not null and not an empty string)
23-
const isMessageToSet = (): boolean => {
22+
// useMemo keeps track of the 'messageTo' value and returns a boolean indicating if it's set
23+
const isMessageToSet = useMemo(() => {
2424
return messageTo !== null && messageTo.trim() !== '';
25-
};
25+
}, [messageTo]);
2626

2727
// Return the 'messageTo' value and the 'isMessageToSet' function
2828
return [messageTo, isMessageToSet];

packages/messenger-widget/src/components/DM3/DM3.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function DM3(props: Dm3Props) {
3333

3434
// sets the DM3 confguration provided from props
3535
setDm3Configuration(props.config);
36-
}, []);
36+
}, [props]);
3737

3838
// This handles the responsive check of widget
3939
useEffect(() => {

0 commit comments

Comments
 (0)