Skip to content

Commit

Permalink
Merge pull request #160 from ligangty/main
Browse files Browse the repository at this point in the history
Use anonymous call instead for all init calls
  • Loading branch information
ligangty authored Jan 25, 2024
2 parents 68de46e + ddd0599 commit 5f32eb9
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ export const PackageTypeSelect = ({register, formErrors}) =>{
const [selected, setSelected] = useState();

useEffect(()=>{
const fetchPkgTypes = async () =>{
(async () =>{
const res = await statsRes.getAllPkgTypes();
if (res.success){
const pkgTypes = res.result;
setState({pkgTypes});
}else{
Utils.logMessage(res);
}
};
fetchPkgTypes();
})();
}, []);

let registered = {};
Expand Down
5 changes: 2 additions & 3 deletions src/main/webui/src/app/components/content/group/GroupList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function GroupList() {

useEffect(() => {
setLoading(true);
const fetchdData = async () => {
(async () => {
const res = await storeRes.getStores(packageType, "group");
if (res.success) {
const timeoutRes = await disableRes.getAllStoreTimeout();
Expand All @@ -85,8 +85,7 @@ export default function GroupList() {
});
}
setLoading(false);
};
fetchdData();
})();
}, [packageType]);

if (loading) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/webui/src/app/components/content/group/GroupView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function GroupView() {

useEffect(()=>{
setLoading(true);
const fetchStore = async () => {
(async () => {
const res = await storeRes.get(packageType, "group", name);
if (res.success){
const raw = res.result;
Expand All @@ -59,9 +59,7 @@ export default function GroupView() {
Utils.logMessage(`Failed to get store data. Error reason: ${res.error.status}->${res.error.message}`);
}
setLoading(false);
};

fetchStore();
})();
}, [packageType, name]);

if (loading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function HostedEdit() {
let store = {"packageType": "maven", "type": "hosted"};
useEffect(()=>{
if(mode === 'edit'){
const fetchStore = async () =>{
(async () =>{
// get Store data
const res = await storeRes.get(packageType, "hosted", name);
if (res.success){
Expand All @@ -77,9 +77,7 @@ export default function HostedEdit() {
// TODO: find another way to do error handling
Utils.logMessage(`Failed to get store data. Error reason: ${res.error.status}->${res.error.message}`);
}
};

fetchStore();
})();
}
}, [packageType, name, mode, reset]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function HostedList() {

useEffect(() => {
setLoading(true);
const fetchdData = async () => {
(async () => {
const res = await storeRes.getStores(packageType, "hosted");
if (res.success) {
const timeoutRes = await disableRes.getAllStoreTimeout();
Expand All @@ -85,8 +85,7 @@ export default function HostedList() {
});
}
setLoading(false);
};
fetchdData();
})();
}, [packageType]);

if (loading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function HostedView() {

useEffect(()=>{
setLoading(true);
const fetchStore = async () => {
(async () => {
const res = await storeRes.get(packageType, "hosted", name);
if (res.success){
const raw = res.result;
Expand All @@ -60,9 +60,7 @@ export default function HostedView() {
Utils.logMessage(`Failed to get store data. Error reason: ${res.error.status}->${res.error.message}`);
}
setLoading(false);
};

fetchStore();
})();
}, [packageType, name]);

if (loading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function RemoteEdit() {
let store = {"packageType": "maven", "type": "remote"};
useEffect(()=>{
if(mode === 'edit'){
const fetchStore = async () =>{
(async () =>{
// get Store data
const res = await storeRes.get(packageType, "remote", name);
if (res.success){
Expand Down Expand Up @@ -86,9 +86,7 @@ export default function RemoteEdit() {
// TODO: find another way to do error handling
Utils.logMessage(`Failed to get store data. Error reason: ${res.error.status}->${res.error.message}`);
}
};

fetchStore();
})();
}
}, [packageType, name, mode, reset]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function RemoteList() {

useEffect(()=>{
setLoading(true);
const fetchdData = async ()=>{
(async ()=>{
const res = await storeRes.getStores(packageType, "remote");
if (res.success){
const timeoutRes = await disableRes.getAllStoreTimeout();
Expand All @@ -85,8 +85,7 @@ export default function RemoteList() {
});
}
setLoading(false);
};
fetchdData();
})();
}, [packageType]);

if (loading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default function RemoteView() {

useEffect(()=>{
setLoading(true);
const fetchStore = async () => {
(async () => {
const res = await storeRes.get(packageType, "remote", name);
if (res.success){
const raw = res.result;
Expand All @@ -188,9 +188,7 @@ export default function RemoteView() {
Utils.logMessage(`Failed to get store data. Error reason: ${res.error.status}->${res.error.message}`);
}
setLoading(false);
};

fetchStore();
})();
}, [packageType, name]);

if (loading) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/webui/src/app/components/nav/NavFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function NavFooter() {
const [state, setState] = useState({stats: {}});

useEffect(()=>{
const fetchVersion = async () => {
(async () => {
const res = await statsRes.getVersion();
if (res.success){
setState({
Expand All @@ -38,9 +38,7 @@ export default function NavFooter() {
Utils.logMessage(`Failed to version info. Error reason: ${res.status}->${data}`);
});
}
};

fetchVersion();
})();
}, []);

const stats = state.stats;
Expand Down
6 changes: 2 additions & 4 deletions src/main/webui/src/app/components/nav/NavHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function NavHeader(){
});

useEffect(()=>{
const fetchUserInfo = async () => {
(async () => {
const res = await authRes.getUserInfo();
if (res.success){
setState({
Expand All @@ -46,9 +46,7 @@ export default function NavHeader(){
Utils.logMessage(`Failed to get user info. Error reason: ${res.status}->${data}`);
});
}
};

fetchUserInfo();
})();
}, []);
return (
<Navbar expand="lg" bg="body-tertiary" fixed="top">
Expand Down
5 changes: 2 additions & 3 deletions src/main/webui/src/content-browse/DirectoryListing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function DirectoryListing () {
});

useEffect(()=>{
const fetchData = async () => {
(async () => {
const res = await contentRes.browse(document.location.pathname);
if(res.success){
const data = res.result;
Expand All @@ -126,8 +126,7 @@ export default function DirectoryListing () {
error: res.error.message
});
}
};
fetchData();
})();
}, []);

const {error, isLoaded, data} = state;
Expand Down

0 comments on commit 5f32eb9

Please sign in to comment.