mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 11:21:30 +01:00
Download Active Response (#49)
This PR prompts you to save un-previewable file types and adds an option to save to the response history.
This commit is contained in:
@@ -5,7 +5,7 @@ import { useLatestHttpResponse } from './useLatestHttpResponse';
|
||||
|
||||
export function usePinnedHttpResponse(activeRequest: HttpRequest) {
|
||||
const latestResponse = useLatestHttpResponse(activeRequest.id);
|
||||
const { set: setPinnedResponseId, value: pinnedResponseId } = useKeyValue<string | null>({
|
||||
const { set, value: pinnedResponseId } = useKeyValue<string | null>({
|
||||
// Key on latest response instead of activeRequest because responses change out of band of active request
|
||||
key: ['pinned_http_response_id', latestResponse?.id ?? 'n/a'],
|
||||
fallback: null,
|
||||
@@ -15,5 +15,13 @@ export function usePinnedHttpResponse(activeRequest: HttpRequest) {
|
||||
const activeResponse: HttpResponse | null =
|
||||
responses.find((r) => r.id === pinnedResponseId) ?? latestResponse;
|
||||
|
||||
const setPinnedResponseId = async (id: string) => {
|
||||
if (pinnedResponseId === id) {
|
||||
await set(null);
|
||||
} else {
|
||||
await set(id);
|
||||
}
|
||||
};
|
||||
|
||||
return { activeResponse, setPinnedResponseId, pinnedResponseId, responses } as const;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user