Skip to content

Commit

Permalink
refactor: remove edit note hack
Browse files Browse the repository at this point in the history
  • Loading branch information
dvirtz committed Dec 6, 2024
1 parent a8919d8 commit fa44e12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/common/musicbrainz/edit-note.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
// from https://github.com/kellnerd/es-utils/blob/main/dom/react.js
function setReactTextareaValue(input: HTMLTextAreaElement, value: string) {
const setter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')?.set?.bind(Object);
setter?.call(input, value);
input.dispatchEvent(new Event('input', {bubbles: true}));
}

export function addEditNote(message: string) {
const textArea = document.querySelector('#edit-note-text') as HTMLTextAreaElement;
const note = editNote(message);
if (!textArea.value.includes(message)) {
setReactTextareaValue(textArea, `${textArea.value}\n${note}`);
MB.relationshipEditor.dispatch({type: 'update-edit-note', editNote: `${textArea.value}\n${note}`});
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/types/MB.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ declare global {
| Array<[Array<RelationshipStateT>, WsJsEditWorkCreateT]>;
responseData: WsJsEditResponseT;
type: 'update-submitted-relationships';
}
| {
editNote: string;
type: 'update-edit-note';
};

type MediumStateTreeT = tree.ImmutableTree<[MediumWithRecordingsT, MediumRecordingStateTreeT]> | null;
Expand Down

0 comments on commit fa44e12

Please sign in to comment.