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

Manager API: Fix api.getAddonStatedefault value #23804

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion code/lib/manager-api/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,13 @@ export function useSharedState<S>(stateId: string, defaultState?: S) {
}

const setState = (s: S | API_StateMerger<S>, options?: Options) => {
const result = api.setAddonState<S>(stateId, s, options);
let sFinal = s;
if (typeof s === 'function') {
sFinal = (_state) => {
return (s as API_StateMerger<S>)(_state || defaultState);
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
};
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
}
const result = api.setAddonState<S>(stateId, sFinal, options);
addonStateCache[stateId] = result;
return result;
};
Expand Down
Loading