Skip to content

Commit

Permalink
feat: change items to compliant name. Closes #163
Browse files Browse the repository at this point in the history
  • Loading branch information
anfibiacreativa committed Dec 11, 2023
1 parent 25498dc commit 9fdea58
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import './chat-action-button.js';

export class ChatHistoryController implements ReactiveController {
host: ReactiveControllerHost;
static CHATHISTORY_ID = 'component:chat-history';
static CHATHISTORY_ID = 'ms-azoaicc:history';

chatHistory: ChatThreadEntry[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export const SettingsStyles = ({ onChange }: Props) => {
};

const getInitialStyles = (): CustomStylesState => {
const storedStyles = localStorage.getItem('customStyles');
const themeStore = localStorage.getItem('isDarkTheme');
const storedStyles = localStorage.getItem('ms-azoaicc:customStyles');
const themeStore = localStorage.getItem('ms-azoaicc:isDarkTheme');
const styleDefaults = themeStore === 'true' ? styleDefaultsDark : styleDefaultsLight;
if (storedStyles === '') {
localStorage.setItem('customStyles', JSON.stringify(styleDefaults));
localStorage.setItem('ms-azoaicc:customStyles', JSON.stringify(styleDefaults));
}
return storedStyles
? JSON.parse(storedStyles)
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/src/components/ThemeSwitch/ThemeSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const ThemeSwitch: React.FC<ThemeSwitchProps> = ({ onToggle, isDarkTheme,
// Toggle 'dark' class on the shell app body element based on the isDarkTheme prop and isConfigPanelOpen
document.body.classList.toggle('dark', isDarkTheme);
document.documentElement.dataset.theme = isDarkTheme && isConfigPanelOpen ? 'dark' : '';
localStorage.removeItem('isDarkTheme');
localStorage.removeItem('ms-azoaicc:isDarkTheme');
}, [isDarkTheme, isConfigPanelOpen]);

return (
Expand Down
20 changes: 10 additions & 10 deletions packages/webapp/src/pages/chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Chat = () => {
const [isLoading] = useState<boolean>(false);

const [isBrandingEnabled, setEnableBranding] = useState(() => {
const storedBranding = localStorage.getItem('isBrandingEnabled');
const storedBranding = localStorage.getItem('ms-azoaicc:isBrandingEnabled');
return storedBranding ? JSON.parse(storedBranding) : false;
});

Expand Down Expand Up @@ -77,7 +77,7 @@ const Chat = () => {
};

const [isDarkTheme, setIsDarkTheme] = useState(() => {
const storedTheme = localStorage.getItem('isDarkTheme');
const storedTheme = localStorage.getItem('ms-azoaicc:isDarkTheme');
return storedTheme ? JSON.parse(storedTheme) : false;
});

Expand Down Expand Up @@ -108,7 +108,7 @@ const Chat = () => {
FontBaseSize: '14px',
};
const defaultStyles = isDarkTheme ? styleDefaultsDark : styleDefaultsLight;
const storedStyles = localStorage.getItem('customStyles');
const storedStyles = localStorage.getItem('ms-azoaicc:customStyles');
return storedStyles ? JSON.parse(storedStyles) : defaultStyles;
});

Expand All @@ -126,7 +126,7 @@ const Chat = () => {
chatComponent.setAttribute('data-theme', newIsDarkTheme ? 'dark' : '');
}
// Update the body class and html data-theme
localStorage.removeItem('customStyles');
localStorage.removeItem('ms-azoaicc:customStyles');

// Update the state
setIsDarkTheme(newIsDarkTheme);
Expand All @@ -135,17 +135,17 @@ const Chat = () => {
useEffect(() => {
// Update the state when local storage changes
const handleStorageChange = () => {
const storedStyles = localStorage.getItem('customStyles');
const storedStyles = localStorage.getItem('ms-azoaicc:customStyles');
if (storedStyles) {
setCustomStyles(JSON.parse(storedStyles));
}

const storedBranding = localStorage.getItem('isBrandingEnabled');
const storedBranding = localStorage.getItem('ms-azoaicc:isBrandingEnabled');
if (storedBranding) {
setEnableBranding(JSON.parse(storedBranding));
}

const storedTheme = localStorage.getItem('isDarkTheme');
const storedTheme = localStorage.getItem('ms-azoaicc:isDarkTheme');
if (storedTheme) {
setIsDarkTheme(JSON.parse(storedTheme));
}
Expand All @@ -155,13 +155,13 @@ const Chat = () => {
window.addEventListener('storage', handleStorageChange);

// Store customStyles in local storage whenever it changes
localStorage.setItem('customStyles', JSON.stringify(customStyles));
localStorage.setItem('ms-azoaicc:customStyles', JSON.stringify(customStyles));

// Store isBrandingEnabled in local storage whenever it changes
localStorage.setItem('isBrandingEnabled', JSON.stringify(isBrandingEnabled));
localStorage.setItem('ms-azoaicc:isBrandingEnabled', JSON.stringify(isBrandingEnabled));

// Store isDarkTheme in local storage whenever it changes
localStorage.setItem('isDarkTheme', JSON.stringify(isDarkTheme));
localStorage.setItem('ms-azoaicc:isDarkTheme', JSON.stringify(isDarkTheme));

// Scroll into view when isLoading changes
chatMessageStreamEnd.current?.scrollIntoView({ behavior: 'smooth' });
Expand Down

0 comments on commit 9fdea58

Please sign in to comment.