258258import type { ContractsOverdue , GridClient } from " @threefold/grid_client" ;
259259import { type Contract , ContractState , NodeStatus , SortByContracts , SortOrder } from " @threefold/gridproxy_client" ;
260260import { DeploymentKeyDeletionError } from " @threefold/types" ;
261- import { computed , defineComponent , onMounted , type Ref , ref } from " vue" ;
261+ import { computed , defineComponent , onMounted , onUnmounted , type Ref , ref } from " vue" ;
262262
263263import ContractsTable from " @/components/contracts_list/contracts_table.vue" ;
264264import { useProfileManagerController } from " @/components/profile_manager_controller.vue" ;
@@ -314,6 +314,7 @@ const nodeInfo: Ref<{ [nodeId: number]: { status: NodeStatus } }> = ref({});
314314const unlockContractLoading = ref <boolean >(false );
315315const contractsTable = ref <(typeof ContractsTable )[]>([]);
316316const loadingLockDetails = ref (false );
317+ const timeouts: ReturnType <typeof setTimeout >[] = [];
317318const nodeIDs = computed <number []>(() => {
318319 const ids = new Set <number >();
319320 for (const contract of contracts .value ) {
@@ -329,6 +330,11 @@ onMounted(() => {
329330 loadContracts ();
330331});
331332
333+ onUnmounted (() => {
334+ timeouts .forEach (timeout => clearTimeout (timeout ));
335+ timeouts .length = 0 ;
336+ });
337+
332338async function _normalizeContracts(
333339 contracts : Contract [],
334340 contractType : ContractType .Node | ContractType .Name | ContractType .Rent ,
@@ -451,10 +457,11 @@ async function unlockAllContracts() {
451457 loadingTablesMessage .value =
452458 " Your request to unlock your contracts has been processed successfully. Changes may take a few minutes to reflect" ;
453459 createCustomToast (loadingTablesMessage .value , ToastType .info );
454- setTimeout (() => {
460+ const timeoutId = setTimeout (() => {
455461 loadContracts ();
456462 loadingTablesMessage .value = undefined ;
457463 }, 30000 );
464+ timeouts .push (timeoutId );
458465 unlockDialog .value = false ;
459466 } catch (e ) {
460467 loadingErrorMessage .value = ` Failed to unlock contract your contracts ` ;
@@ -479,10 +486,11 @@ async function deleteAll() {
479486 loadingTablesMessage .value =
480487 " The contracts have been successfully deleted. Please note that all tables will be reloaded in 30 seconds." ;
481488 createCustomToast (loadingTablesMessage .value , ToastType .info );
482- setTimeout (() => {
489+ const timeoutId = setTimeout (() => {
483490 loadContracts ();
484491 loadingTablesMessage .value = undefined ;
485492 }, 30000 );
493+ timeouts .push (timeoutId );
486494 } catch (e ) {
487495 if (e instanceof DeploymentKeyDeletionError ) {
488496 createCustomToast (" Failed to delete some keys, You don't have enough tokens" , ToastType .danger );
@@ -551,10 +559,11 @@ async function onDeletedContracts(_contracts: NormalizedContract[]) {
551559 loadingTablesMessage .value =
552560 " The contracts have been successfully deleted. Please note that all tables will be reloaded in 30 seconds." ;
553561 createCustomToast (loadingTablesMessage .value , ToastType .info );
554- setTimeout (() => {
562+ const timeoutId = setTimeout (() => {
555563 loadContracts ();
556564 loadingTablesMessage .value = undefined ;
557565 }, 30000 );
566+ timeouts .push (timeoutId );
558567 contracts .value = [... rentContracts .value , ... nameContracts .value , ... nodeContracts .value ];
559568}
560569async function getContractsLockDetails() {
0 commit comments