= ({
diff --git a/packages/uiweb/src/lib/components/space/SpaceWidget/SpaceWidget.tsx b/packages/uiweb/src/lib/components/space/SpaceWidget/SpaceWidget.tsx
index a3534585b..2a0ea7fe1 100644
--- a/packages/uiweb/src/lib/components/space/SpaceWidget/SpaceWidget.tsx
+++ b/packages/uiweb/src/lib/components/space/SpaceWidget/SpaceWidget.tsx
@@ -142,7 +142,7 @@ const Container = styled.div`
border: 1px solid ${(props) => props.theme.borderColor}; // update acc to theme
display: flex;
flex-direction: column;
- width: ${(props) => (props.width ? `${props.width}px` : 'auto')};
+ width: ${(props) => (props.width ? `${props.width}px` : `${DEFAULT_MAXWIDTH}px`)};
max-width: ${(props) =>
props.width ? `${props.width}px` : `${DEFAULT_MAXWIDTH}px`};
min-width: 320px;
diff --git a/packages/uiweb/src/lib/helpers/chat/localStorage.ts b/packages/uiweb/src/lib/helpers/chat/localStorage.ts
index 4d7dac903..9ceedaaf9 100644
--- a/packages/uiweb/src/lib/helpers/chat/localStorage.ts
+++ b/packages/uiweb/src/lib/helpers/chat/localStorage.ts
@@ -61,3 +61,12 @@ export const setPfp = ({
}) => {
localStorage.setItem(account, value);
};
+
+export const setAccessControl = (chatId: string, toRemove: boolean) => {
+ if (toRemove) {
+ localStorage.removeItem(chatId);
+ } else {
+ const timestamp = new Date().getTime();
+ localStorage.setItem(chatId, JSON.stringify(timestamp));
+ }
+};
diff --git a/packages/uiweb/src/lib/hooks/chat/usePushSendMessage.ts b/packages/uiweb/src/lib/hooks/chat/usePushSendMessage.ts
index 7b202d7d0..415799e77 100644
--- a/packages/uiweb/src/lib/hooks/chat/usePushSendMessage.ts
+++ b/packages/uiweb/src/lib/hooks/chat/usePushSendMessage.ts
@@ -1,8 +1,9 @@
import * as PushAPI from '@pushprotocol/restapi';
import { useCallback, useContext, useState } from 'react';
-
+import useVerifyAccessControl from './useVerifyAccessControl';
import { useChatData } from '..';
import { ENV } from '../../config';
+import { setAccessControl } from '../../helpers';
interface SendMessageParams {
message: string;
@@ -14,6 +15,8 @@ const usePushSendMessage = () => {
const [error, setError] = useState();
const [loading, setLoading] = useState(false);
+ const { verificationSuccessfull, setVerificationSuccessfull, setVerified } =
+ useVerifyAccessControl();
const { pgpPrivateKey, env, account } = useChatData();
const sendMessage = useCallback(
@@ -30,12 +33,17 @@ const usePushSendMessage = () => {
env: env,
});
setLoading(false);
- console.log(response, "resssponssseeee");
+ console.log(response);
if (!response) {
return false;
}
return;
} catch (error: Error | any) {
+ if (error.message.includes('400')) {
+ setAccessControl(chatId, true);
+ setVerified(false);
+ setVerificationSuccessfull(false);
+ }
setLoading(false);
setError(error.message);
console.log(error);
diff --git a/packages/uiweb/src/lib/hooks/chat/useVerifyAccessControl.ts b/packages/uiweb/src/lib/hooks/chat/useVerifyAccessControl.ts
index 114109c5a..f50ce89f6 100644
--- a/packages/uiweb/src/lib/hooks/chat/useVerifyAccessControl.ts
+++ b/packages/uiweb/src/lib/hooks/chat/useVerifyAccessControl.ts
@@ -2,6 +2,7 @@ import * as PushAPI from '@pushprotocol/restapi';
import { useCallback, useState } from 'react';
import { ENV } from '../../config';
import { useChatData } from './useChatData';
+import { setAccessControl } from '../../helpers';
interface VerifyAccessControlParams {
chatId: string;
@@ -17,6 +18,7 @@ const useVerifyAccessControl = () => {
const { pgpPrivateKey, env, account } = useChatData();
+ console.log('Verification control hook');
const verifyAccessControl = useCallback(
async (options: VerifyAccessControlParams) => {
const { chatId, did } = options || {};
@@ -32,11 +34,7 @@ const useVerifyAccessControl = () => {
setVerificationSuccessfull(false);
} else if (response.chatAccess === true) {
setVerified(true);
- const timestamp = new Date().getTime();
- localStorage.setItem(
- chatId,
- JSON.stringify(timestamp)
- );
+ setAccessControl(chatId, false);
}
console.log(response);
if (!response) {
@@ -51,9 +49,17 @@ const useVerifyAccessControl = () => {
return;
}
},
- [pgpPrivateKey, account]
+ [pgpPrivateKey, account, verificationSuccessfull, verified, setVerified]
);
- return { verifyAccessControl, error, loading, verificationSuccessfull, setVerificationSuccessfull, verified, setVerified };
+ return {
+ verifyAccessControl,
+ error,
+ loading,
+ verificationSuccessfull,
+ setVerificationSuccessfull,
+ verified,
+ setVerified,
+ };
};
export default useVerifyAccessControl;