feat: Add Global Module Settings and Caption to Images
- Introduced GlobalModuleSettings model for platform-wide module enable/disable settings. - Added 'caption' field to Images model to store image captions. - Updated GenerateImagePromptsFunction to handle new caption structure in prompts. - Enhanced AIPromptViewSet to return global prompt types and validate active prompts. - Modified serializers and views to accommodate new caption field and global settings. - Updated frontend components to display captions and filter prompts based on active types. - Created migrations for GlobalModuleSettings and added caption field to Images.
This commit is contained in:
@@ -21,6 +21,9 @@ import {
|
||||
AccountSettingsError,
|
||||
} from '../services/api';
|
||||
|
||||
// Version for cache busting - increment when structure changes
|
||||
const SETTINGS_STORE_VERSION = 2;
|
||||
|
||||
const getAccountSettingsErrorMessage = (error: AccountSettingsError): string => {
|
||||
switch (error.type) {
|
||||
case 'ACCOUNT_SETTINGS_NOT_FOUND':
|
||||
@@ -241,11 +244,23 @@ export const useSettingsStore = create<SettingsState>()(
|
||||
}),
|
||||
{
|
||||
name: 'settings-storage',
|
||||
version: SETTINGS_STORE_VERSION, // Add version for cache busting
|
||||
partialize: (state) => ({
|
||||
accountSettings: state.accountSettings,
|
||||
moduleSettings: state.moduleSettings,
|
||||
moduleEnableSettings: state.moduleEnableSettings,
|
||||
}),
|
||||
// Migrate function to handle version changes
|
||||
migrate: (persistedState: any, version: number) => {
|
||||
if (version < SETTINGS_STORE_VERSION) {
|
||||
// Clear module enable settings on version upgrade
|
||||
return {
|
||||
...persistedState,
|
||||
moduleEnableSettings: null,
|
||||
};
|
||||
}
|
||||
return persistedState;
|
||||
},
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user