Add getLocalPrompt and setLocalPrompt functions to preferenceApi.ts

This commit is contained in:
Alex
2023-12-04 11:23:51 +02:00
parent 453e507b89
commit f8f60c62fe
3 changed files with 24 additions and 1 deletions

View File

@@ -81,6 +81,16 @@ prefListenerMiddleware.startListening({
},
});
prefListenerMiddleware.startListening({
matcher: isAnyOf(setPrompt),
effect: (action, listenerApi) => {
localStorage.setItem(
'DocsGPTPrompt',
JSON.stringify((listenerApi.getState() as RootState).preference.prompt),
);
},
});
export const selectApiKey = (state: RootState) => state.preference.apiKey;
export const selectApiKeyStatus = (state: RootState) =>
!!state.preference.apiKey;