-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat (settings): Verification grid level default settings for spectrograms #226
base: main
Are you sure you want to change the base?
Conversation
public set defaultSpectrogramOptions(options: SpectrogramOptions) { | ||
// TODO: make this a lot better | ||
const currentOptions = this.spectrogramOptions; | ||
const currentDefaults = this.defaultOptions; | ||
const newOptions = currentOptions; | ||
|
||
const newOptionEntries = Object.entries(options); | ||
|
||
for (const [key, value] of newOptionEntries) { | ||
if ((options as any)[key] === (currentDefaults as any)[key]) { | ||
continue; | ||
} | ||
|
||
const isDefault = (currentDefaults as any)[key] === (currentOptions as any)[key]; | ||
if (isDefault) { | ||
console.debug(`Setting default option ${key} to ${value}`); | ||
(newOptions as any)[key] = value; | ||
} else { | ||
(newOptions as any)[key] = (currentOptions as any)[key]; | ||
} | ||
} | ||
|
||
this.defaultOptions = options; | ||
this.spectrogramOptions = newOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typing here is really poor, I should improve it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to talk about the architecture of this. What is problematic is the change cycle seems to be running through the media controls
For each component that uses settings, I expect to see:
- subscription to a signal
- on signal:
currentSettings = Object.assign({}, this.defaultSettings, this.globalSettings, this.attributeSettings
OR, each individual setting is a signal:
e.g. windowSize : Signal<integer> = settingHelper(nameof(windowSize))
implementation is something like
coalesce(this[propertyName], this.globalSettings.value()[propertyName])
const spectrogramOptionsSignal = signal<SpectrogramOptions>(this.spectrogramElement.spectrogramOptions); | ||
spectrogramOptionsSignal.subscribe((newOptions) => { | ||
if (!this.spectrogramElement) { | ||
throw new Error( | ||
"No spectrogram element found. This might be because you forgot to unsubscribe from the options signal", | ||
); | ||
} | ||
this.spectrogramElement.spectrogramOptions = newOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be a recursive definition.
but also, why is it the job of media controls to set the options on a spectrogram?
const axesOptionsSignal = signal<AxesOptions>(this.axesElement.axesOptions); | ||
axesOptionsSignal.subscribe((newOptions) => { | ||
if (!this.axesElement) { | ||
throw new Error( | ||
"No axes element found. This might be because you forgot to unsubscribe from the options signal", | ||
); | ||
} | ||
this.axesElement.axesOptions = newOptions; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Feat (settings): Verification grid level default settings for spectrograms
Changes
Remaining Bugs / Unresolved Problems
Visual Changes
Related Issues
Fixes: #179
Final Checklist
pnpm lint
runs without any errorspnpm test
runs without any errors