Skip to content

Error handling when room schedule fetch fails #32

Open
@adapap

Description

@adapap

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;
			}
		}
	}
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreworkRefactoring code, improving performance/efficiency, changing structure or organization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions