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: add info switch functionality #32

Merged
merged 7 commits into from
Nov 22, 2023
Merged

feat: add info switch functionality #32

merged 7 commits into from
Nov 22, 2023

Conversation

TobyBridle
Copy link
Contributor

Allow modules to provide a way to switch between modes within the info page.
This is done using the following interface

interface SwitchConfig {
    // E.g ["Dub", "Sub"]
    options: [string, string];
    // E.g 0 ("Dub")
    default: number;
    // E.g True to not request the same URL twice (does not hold true across seasons)
    cache: boolean;
    // E.g True to re-request the Info page as well
    includeInfo: boolean;
}

The module must then implement a getSwitchConfig function which returns this SwitchConfig.
Within the module, the value of the switch can be retrieved via getSwitchValue.
For example, to get the label for the active option, you would do:

const appSwitch = switchConfig.options[getSwitchValue()];
// switch is 0 -> appSwitch = "Dub"
// switch is 1 -> appSwitch = "Sub"

@TobyBridle
Copy link
Contributor Author

I have purposefully not made this a draft so that it can build - please DO NOT merge yet.

@TobyBridle
Copy link
Contributor Author

I was going to increment the format version for this but, since it's backwards compatible anyway, I don't think I will

@TobyBridle TobyBridle merged commit e4d1f25 into dev Nov 22, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant