Skip to content

Commit

Permalink
fix(split links): adjust links editor properties for new MBS beta
Browse files Browse the repository at this point in the history
  • Loading branch information
ROpdebee committed Jul 5, 2022
1 parent e31be17 commit 930c717
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/lib/MB/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export interface ExternalLinks {

export interface ReleaseEditor {
externalLinks: {
current: ExternalLinks;
externalLinksEditorRef: {
current: ExternalLinks;
};
};
}

Expand All @@ -29,7 +31,9 @@ declare global {
MB: {
releaseEditor?: ReleaseEditor;
sourceExternalLinksEditor?: {
current: ExternalLinks;
externalLinksEditorRef: {
current: ExternalLinks;
};
};
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/mb_multi_external_links/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ExternalLinks } from '@lib/MB/types';
import { ConsoleSink } from '@lib/logging/consoleSink';
import { LogLevel } from '@lib/logging/levels';
import { LOGGER } from '@lib/logging/logger';
import { assertDefined } from '@lib/util/assert';
import { assertHasValue } from '@lib/util/assert';
import { logFailure, retryTimes } from '@lib/util/async';
import { createPersistentCheckbox } from '@lib/util/checkboxes';
import { onAddEntityDialogLoaded, qsa, qsMaybe, setInputValue } from '@lib/util/dom';
Expand All @@ -14,8 +14,8 @@ import USERSCRIPT_ID from 'consts:userscript-id';

function getExternalLinksEditor(mbInstance: typeof window.MB): ExternalLinks {
// Can be found in the MB object, but exact property depends on actual page.
const editor = (mbInstance.releaseEditor?.externalLinks ?? mbInstance.sourceExternalLinksEditor)?.current;
assertDefined(editor, 'Cannot find external links editor object');
const editor = (mbInstance.releaseEditor?.externalLinks ?? mbInstance.sourceExternalLinksEditor)?.externalLinksEditorRef.current;
assertHasValue(editor, 'Cannot find external links editor object');
return editor;
}

Expand Down

0 comments on commit 930c717

Please sign in to comment.