Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmieszczak committed Jun 3, 2024
1 parent 10b58d1 commit 09c163c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion api/server/routes/convos.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ router.get('/export/jobs/:jobId', jobStatusHandler);
router.get('/export/jobs/:jobId/conversations.json', async (req, res) => {
logger.info('Downloading JSON file');
try {
//put this in a function
const { jobId } = req.params;
const tempDir = os.tmpdir();
const filePath = path.join(tempDir, `export-${jobId}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ function ExportConversations() {
const exportFile = useExportConversationsMutation({
onSuccess: (data) => {
console.log('Exporting started', data);

showToast({ message: localize('com_ui_export_conversation_success') });

// Directly initiate download here if `data` contains downloadable content or URL
downloadConversationsJsonFile(data);
},
onError: (error) => {
Expand All @@ -35,7 +32,6 @@ function ExportConversations() {
};

const downloadConversationsJsonFile = (data) => {
// Assuming `data` is the downloadable content; adjust as necessary for your use case
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);

Expand Down
16 changes: 10 additions & 6 deletions client/src/data-provider/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,21 +404,25 @@ export const useExportConversationsMutation = (
}, 500); // Poll every 0,5 seconds. Adjust time as necessary.
};

return useMutation<t.ImportStartResponse, unknown, FormData>({
return useMutation<t.TImportStartResponse, unknown, FormData>({
mutationFn: (formData: FormData) => dataService.exportAllConversationsToJson(formData),
onSuccess: (data) => {
queryClient.invalidateQueries(QueryKeys.allConversations);
onSuccess: (data, variables, context) => {
queryClient.invalidateQueries([QueryKeys.allConversations]);
const jobId = data.jobId;
if (jobId) {
console.log('Job ID:', jobId);
pollJobStatus(
jobId,
async () => {
queryClient.invalidateQueries(QueryKeys.allConversations);
onSuccess?.(await dataService.exportConversationsFile(jobId));
queryClient.invalidateQueries([QueryKeys.allConversations]);
onSuccess?.(
(await dataService.exportConversationsFile(jobId)).data,
variables,
context,
);
},
(error) => {
onError?.(error, { jobId }, { context: 'ExportJobFailed' });
onError?.(error, variables, { context: 'ExportJobFailed' });
},
);
}
Expand Down

0 comments on commit 09c163c

Please sign in to comment.