Skip to content

Commit

Permalink
Fix broken form parsing
Browse files Browse the repository at this point in the history
More fallout from refactoring that I didn't double check.
  • Loading branch information
danrahn committed Apr 30, 2024
1 parent 8c9e429 commit f150ab7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Client/Script/MarkerTableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class ExistingMarkerRow extends MarkerRow {
/** @type {MediaItemWithMarkerTable} */
const mediaItem = this.baseItemRow().mediaItem();
await flashBackground(confirmBtn, Theme.getHex(ThemeColors.Green, '6'), 200);
Tooltip.dismiss();
mediaItem.markerTable().deleteMarker(deletedMarker, this.row());
} catch (err) {
ButtonCreator.setIcon(confirmBtn, Icons.Confirm, ThemeColors.Red);
Expand Down Expand Up @@ -301,6 +302,7 @@ class ExistingMarkerRow extends MarkerRow {
options.removeChild(confButtons);
options.children[0].classList.remove('hidden');
$$('.deleteMarkerBtn', options)?.focus();
Tooltip.dismiss();

return Promise.all([
animateOpacity(dateAdded.children[0], 0, 1, { duration : 100, noReset : true }),
Expand Down
2 changes: 1 addition & 1 deletion Server/ImportExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,5 +457,5 @@ WHERE (base.metadata_type=1 OR base.metadata_type=4)`;
* Register POST handlers related to custom marker database import/export. */
export function registerImportExportCommands() {
registerCommand(PostCommands.ImportDb,
q => DatabaseImportExport.importDatabase(q.fs('database'), q.fi('sectionId'), q.fi('resolveType')));
q => DatabaseImportExport.importDatabase(q.fr('database'), q.fi('sectionId'), q.fi('resolveType')));
}
11 changes: 9 additions & 2 deletions Server/QueryParse.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class QueryParser {
* Retrieve a value from the request's form-data.
* @param {string} key */
fi(key) {
const value = parseInt((this.fs(key)).data);
const value = parseInt((this.fs(key)));
if (isNaN(value)) {
throw new QueryParameterException(`Expected an integer for '${key}', found something else.`);
}
Expand All @@ -137,13 +137,20 @@ export class QueryParser {
* @param {(v: string) => any} transform The function that transforms the raw string to a custom object. */
fc(key, transform) {
// transform should take care of any exceptions.
return transform(this.fs(key).data);
return transform(this.fs(key));
}

/**
* Retrieve the raw string associated with the given key from the request's form data.
* @param {string} key The form field to retrieve */
fs(key) {
return this.fr(key).data;
}

/**
* Return the raw form object for the given key.
* @param {string} key The form field to retrieve */
fr(key) {
if (!this.#formData) {
throw new ServerError(`Attempting to access form data without calling init().`, 500);
}
Expand Down

0 comments on commit f150ab7

Please sign in to comment.