Skip to content

Commit

Permalink
Bug fix for getting collection issues notifications (#204)
Browse files Browse the repository at this point in the history
* fixed a bug with getting collection issues notifications

* audit fix
  • Loading branch information
trean authored Aug 15, 2024
1 parent 9bd7426 commit 4eba245
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
23 changes: 20 additions & 3 deletions src/common/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,26 @@ import axios from 'axios';
import { getBaseURL } from './utils';
import { bigIntJSON } from './bigIntJSON';

function setupAxios({ apiKey }) {
export const axiosInstance = axios.create({
baseURL: process.env.NODE_ENV === 'development' ? 'http://localhost:6333' : getBaseURL(),
transformRequest: [
function (data, headers) {
if (data instanceof FormData) {
return data;
}
headers['Content-Type'] = 'application/json';
headers['x-inference-proxy'] = 'true';
return bigIntJSON.stringify(data);
},
],
transformResponse: [
function (data) {
return bigIntJSON.parse(data);
},
],
});

export function setupAxios(axios, { apiKey }) {
if (process.env.NODE_ENV === 'development') {
axios.defaults.baseURL = 'http://localhost:6333';
} else {
Expand All @@ -27,5 +46,3 @@ function setupAxios({ apiKey }) {
},
];
}

export default setupAxios;
2 changes: 1 addition & 1 deletion src/components/CodeEditorWindow/config/RequesFromCode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from 'axios';
import { axiosInstance as axios } from '../../../common/axios';
import { stripComments } from 'jsonc-parser';
import { updateHistory } from '../../../lib/update-history';
import { bigIntJSON } from '../../../common/bigIntJSON';
Expand Down
6 changes: 5 additions & 1 deletion src/components/Notifications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
import List from '@mui/material/List';
import MuiListItem from '@mui/material/ListItem';
import MuiDivider from '@mui/material/Divider';
import axios from 'axios';
import { axiosInstance as axios } from '../common/axios';
import { CodeBlock } from './Common/CodeBlock';
import { Box, Button, Chip, Drawer, useMediaQuery } from '@mui/material';
import { requestFromCode } from './CodeEditorWindow/config/RequesFromCode';
Expand Down Expand Up @@ -69,6 +69,10 @@ export default function Notifications() {
React.useEffect(() => {
setLoading(true);
fetchNotifications().then((data) => {
if (!data || data.length === 0) {
setLoading(false);
return;
}
setIssuesCount(data.length);
setIssues(data);
setLoading(false);
Expand Down
4 changes: 2 additions & 2 deletions src/context/client-context.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext, createContext, useState, useEffect } from 'react';
import setupAxios from '../common/axios';
import { axiosInstance, setupAxios } from '../common/axios';
import qdrantClient from '../common/client';
import { bigIntJSON } from '../common/bigIntJSON';

Expand Down Expand Up @@ -35,7 +35,7 @@ export const ClientProvider = (props) => {
const client = qdrantClient(settings);

useEffect(() => {
setupAxios(settings);
setupAxios(axiosInstance, settings);
persistSettings(settings);
}, [settings]);

Expand Down

0 comments on commit 4eba245

Please sign in to comment.