Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading in contracts table #2801

Merged
merged 2 commits into from
Jun 4, 2024
Merged

Conversation

0oM4R
Copy link
Contributor

@0oM4R 0oM4R commented May 28, 2024

Description

the issue was that we were set loading for other table to false before it already done and it shows no data for while before finish listing its contract

Changes

add new function that handle updating loading value of tables

Related Issues

please note that this pr is fixing loading issue only, there are other issues got opened related to contracts table #2800 and #2798

Documentation PR

For UI changes, Please provide the Documetation PR on info_grid

Screencast.from.28.2024.EEST.05.43.03.webm

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstrings
  • Screenshots/Video attached (needed for UI changes)

Copy link
Contributor

@AlaaElattar AlaaElattar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked ur function a lot. Great Job

@@ -218,6 +218,18 @@ const nodeIDs = computed(() => {
return [...new Set(allContracts.value.map(contract => contract.details.nodeId) || [])];
});

function updateLoadingTableValue(updateAllTables: boolean, loading = true, contractType?: ContractType) {
if (updateAllTables) {
Copy link
Contributor

@xmonader xmonader May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could do a switch on contractType if your actions are going to be different, and also you don't need elseifs in your code given you do a return already in updateAllTables so you can safely start a new if or a switch

if updateAllTables {
            .... 
            return 
 }
switch contractType {
         case contractType.Name: 
                     isLoadingName.value = loading
                     break
         case 2: ...
         case 3:..
 }

Copy link
Contributor

@Mahmoud-Emad Mahmoud-Emad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job ya Omar :)

isLoadingNode.value = false;
isLoadingName.value = false;
isLoadingRent.value = false;
updateLoadingTableValue(true, false);
Copy link
Contributor

@Mahmoud-Emad Mahmoud-Emad May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO. To improve code readability and maintainability, consider introducing an object instead of using named parameters.

// Define a type for the options
type ContractsLoadingOptions = {
  updateAllTables: boolean;
  loading: boolean;
  contractType?: boolean;
}

function updateContractsLoading(options: ContractsLoadingOptions) {}

// Example call
updateContractsLoading({
  updateAllTables: true,
  loading: false,
});

- replace elseif with switch case
- use options object nstead of using named parameters
@0oM4R 0oM4R requested review from Mahmoud-Emad and xmonader June 4, 2024 06:54
@0oM4R 0oM4R merged commit 0dc37b1 into development Jun 4, 2024
3 checks passed
@0oM4R 0oM4R deleted the development_contractsTable_loading branch June 4, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants