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