Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hudson-newey
Copy link
Member

@hudson-newey hudson-newey commented Oct 15, 2024

Feat (settings): Verification grid level default settings for spectrograms

Changes

Remaining Bugs / Unresolved Problems

Visual Changes

Related Issues

Fixes: #179

Final Checklist

  • All commits messages are semver compliant
  • Added relevant unit tests for new functionality
  • Updated existing unit tests to reflect changes
  • Code style is consistent with the project guidelines
  • Documentation is updated to reflect the changes (if applicable)
  • Link issues related to the PR
  • Assign labels if you have permission
  • Assign reviewers if you have permission
  • Ensure that CI is passing
  • Ensure that pnpm lint runs without any errors
  • Ensure that pnpm test runs without any errors

Copy link

@hudson-newey hudson-newey changed the title Feat (settings): Global settings for spectrograms Feat (settings): Verification grid level default settings for spectrograms Oct 15, 2024
@hudson-newey hudson-newey self-assigned this Oct 15, 2024
Comment on lines +163 to +186
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;
Copy link
Member Author

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

@hudson-newey hudson-newey changed the title Feat (settings): Verification grid level default settings for spectrograms feat (settings): Verification grid level default settings for spectrograms Feb 6, 2025
@hudson-newey hudson-newey marked this pull request as ready for review February 6, 2025 01:58
Copy link
Contributor

@atruskie atruskie left a 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])

Comment on lines +188 to +195
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;
Copy link
Contributor

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?

Comment on lines +198 to +206
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;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global Setting: Spectrogram axis, colour and labels
2 participants