feat: use recordingUrl instead of currentUrl
This commit is contained in:
@@ -12,6 +12,7 @@ import { UrlForm } from './UrlForm';
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { useSocketStore } from "../../context/socket";
|
import { useSocketStore } from "../../context/socket";
|
||||||
import { getCurrentUrl } from "../../api/recording";
|
import { getCurrentUrl } from "../../api/recording";
|
||||||
|
import { useGlobalInfoStore } from '../../context/globalInfo';
|
||||||
|
|
||||||
const StyledNavBar = styled.div<{ browserWidth: number }>`
|
const StyledNavBar = styled.div<{ browserWidth: number }>`
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -31,8 +32,7 @@ const BrowserNavBar: FC<NavBarProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
|
const { recordingUrl, setRecordingUrl } = useGlobalInfoStore();
|
||||||
const [currentUrl, setCurrentUrl] = useState<string>('https://');
|
|
||||||
|
|
||||||
const handleRefresh = useCallback((): void => {
|
const handleRefresh = useCallback((): void => {
|
||||||
socket?.emit('input:refresh');
|
socket?.emit('input:refresh');
|
||||||
@@ -44,14 +44,13 @@ const BrowserNavBar: FC<NavBarProps> = ({
|
|||||||
|
|
||||||
const handleCurrentUrlChange = useCallback((url: string) => {
|
const handleCurrentUrlChange = useCallback((url: string) => {
|
||||||
handleUrlChanged(url);
|
handleUrlChanged(url);
|
||||||
setCurrentUrl(url);
|
setRecordingUrl(url);
|
||||||
}, [handleUrlChanged, currentUrl]);
|
}, [handleUrlChanged, recordingUrl]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getCurrentUrl().then((response) => {
|
getCurrentUrl().then((response) => {
|
||||||
if (response) {
|
if (response) {
|
||||||
handleUrlChanged(response);
|
handleUrlChanged(response);
|
||||||
setCurrentUrl(response);
|
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.log("Fetching current url failed");
|
console.log("Fetching current url failed");
|
||||||
@@ -72,6 +71,7 @@ const BrowserNavBar: FC<NavBarProps> = ({
|
|||||||
const addAddress = (address: string) => {
|
const addAddress = (address: string) => {
|
||||||
if (socket) {
|
if (socket) {
|
||||||
handleUrlChanged(address);
|
handleUrlChanged(address);
|
||||||
|
setRecordingUrl(address);
|
||||||
handleGoTo(address);
|
handleGoTo(address);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -111,7 +111,7 @@ const BrowserNavBar: FC<NavBarProps> = ({
|
|||||||
</NavBarButton>
|
</NavBarButton>
|
||||||
|
|
||||||
<UrlForm
|
<UrlForm
|
||||||
currentAddress={currentUrl}
|
currentAddress={recordingUrl}
|
||||||
handleRefresh={handleRefresh}
|
handleRefresh={handleRefresh}
|
||||||
setCurrentAddress={addAddress}
|
setCurrentAddress={addAddress}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user