mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
Fix recent requests loading on startup
This commit is contained in:
@@ -91,8 +91,6 @@ async fn actually_send_ephemeral_request(
|
|||||||
url_string = format!("http://{}", url_string);
|
url_string = format!("http://{}", url_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Sending request to {}", url_string);
|
|
||||||
|
|
||||||
let client = reqwest::Client::builder()
|
let client = reqwest::Client::builder()
|
||||||
.redirect(Policy::none())
|
.redirect(Policy::none())
|
||||||
// .danger_accept_invalid_certs(true)
|
// .danger_accept_invalid_certs(true)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ const validateHttpHeader = (v: string) => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hi = v.replace(/\$\{\[\s*[^\]\s]+\s*]}/gi, 'fo');
|
// Template strings are not allowed so we replace them with a valid example string
|
||||||
console.log('V', v, '-->', hi);
|
const withoutTemplateStrings = v.replace(/\$\{\[\s*[^\]\s]+\s*]}/gi, '123');
|
||||||
return v.match(/^[a-zA-Z0-9-_]+$/) !== null;
|
return withoutTemplateStrings.match(/^[a-zA-Z0-9-_]+$/) !== null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ export function RecentRequestsDropdown() {
|
|||||||
const dropdownRef = useRef<DropdownRef>(null);
|
const dropdownRef = useRef<DropdownRef>(null);
|
||||||
const activeRequest = useActiveRequest();
|
const activeRequest = useActiveRequest();
|
||||||
const activeWorkspaceId = useActiveWorkspaceId();
|
const activeWorkspaceId = useActiveWorkspaceId();
|
||||||
const recentRequestIds = useRecentRequests();
|
|
||||||
const requests = useRequests();
|
const requests = useRequests();
|
||||||
const routes = useAppRoutes();
|
const routes = useAppRoutes();
|
||||||
|
const allRecentRequestIds = useRecentRequests();
|
||||||
|
const recentRequestIds = useMemo(() => allRecentRequestIds.slice(1), [allRecentRequestIds]);
|
||||||
|
|
||||||
// Toggle the menu on Cmd+k
|
// Toggle the menu on Cmd+k
|
||||||
useKey('k', (e) => {
|
useKey('k', (e) => {
|
||||||
|
|||||||
@@ -14,23 +14,26 @@ export function useRecentRequests() {
|
|||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
// Load local storage state on initial render
|
||||||
setLSState(history);
|
|
||||||
}, [history, setLSState]);
|
|
||||||
|
|
||||||
useEffectOnce(() => {
|
useEffectOnce(() => {
|
||||||
if (lsState) {
|
if (lsState) {
|
||||||
setHistory(lsState);
|
setHistory(lsState);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Update local storage state when history changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setHistory((h: string[]) => {
|
setLSState(history);
|
||||||
if (activeRequestId === null) return h;
|
}, [history, setLSState]);
|
||||||
const withoutCurrentRequest = h.filter((id) => id !== activeRequestId);
|
|
||||||
|
// Set history when active request changes
|
||||||
|
useEffect(() => {
|
||||||
|
setHistory((currentHistory: string[]) => {
|
||||||
|
if (activeRequestId === null) return currentHistory;
|
||||||
|
const withoutCurrentRequest = currentHistory.filter((id) => id !== activeRequestId);
|
||||||
return [activeRequestId, ...withoutCurrentRequest];
|
return [activeRequestId, ...withoutCurrentRequest];
|
||||||
});
|
});
|
||||||
}, [activeRequestId, setHistory]);
|
}, [activeRequestId, setHistory]);
|
||||||
|
|
||||||
return history.slice(1);
|
return history;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user