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

Error handling when room schedule fetch fails #32

Open
adapap opened this issue Mar 14, 2020 · 0 comments
Open

Error handling when room schedule fetch fails #32

adapap opened this issue Mar 14, 2020 · 0 comments
Labels
bug Something isn't working rework Refactoring code, improving performance/efficiency, changing structure or organization

Comments

@adapap
Copy link
Collaborator

adapap commented Mar 14, 2020

When the fetch for the Room Availability feature fails, the error is not caught and reported accordingly resulting in a stream of extension/console errors. I believe this can be fixed by using a .catch before .then in FreeRooms:getAvailableRooms.

Also I think a lot of the code can be written more nicely with the new jQuery style syntax through Cash. For example, the following:

let dataElements = row.querySelectorAll('td');
for (let td of dataElements) {
if (td.hasAttribute('colspan')) {
totalColspan += parseInt(td.getAttribute('colspan'));
if (totalColspan >= colspanTime) {
if (td.innerHTML === '') {
flag = true;
} else {
break;
}
}
}
}

can be simplified to:

$(td).each((i, x) => {
	// The reason why we need to do $(x) is because x is an HTMLElement, which can only
	// be manipulated with native JavaScript (i.e. x.hasAttr('colspan'), x.innerHTML)
	let colspan = $(x).attr('colspan');
	if (colspan) {
		totalColspan += parseInt(colspan);
		if (totalColspan >= colspanTime) {
			if ($(x).html() === '') {
				flag = true;
			} else {
				break;
			}
		}
	}
})
@adapap adapap added bug Something isn't working rework Refactoring code, improving performance/efficiency, changing structure or organization labels Mar 14, 2020
@dcarpenter31 dcarpenter31 removed their assignment May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rework Refactoring code, improving performance/efficiency, changing structure or organization
Projects
None yet
Development

No branches or pull requests

2 participants