feat(P3-6): configurable composer toolbar buttons
Each button (Format, Emoji, Sticker, GIF, Location, Poll, Voice, Schedule) can be individually hidden in Settings → Editor. All default to on, stored in composerToolbarButtons object. getSettings deep-merges the nested object so new buttons default to true for existing users with saved settings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,28 @@ export enum MessageLayout {
|
||||
Bubble = 2,
|
||||
}
|
||||
|
||||
export interface ComposerToolbarSettings {
|
||||
showFormat: boolean;
|
||||
showEmoji: boolean;
|
||||
showSticker: boolean;
|
||||
showGif: boolean;
|
||||
showLocation: boolean;
|
||||
showPoll: boolean;
|
||||
showVoice: boolean;
|
||||
showSchedule: boolean;
|
||||
}
|
||||
|
||||
export const DEFAULT_COMPOSER_TOOLBAR: ComposerToolbarSettings = {
|
||||
showFormat: true,
|
||||
showEmoji: true,
|
||||
showSticker: true,
|
||||
showGif: true,
|
||||
showLocation: true,
|
||||
showPoll: true,
|
||||
showVoice: true,
|
||||
showSchedule: true,
|
||||
};
|
||||
|
||||
export interface Settings {
|
||||
themeId?: string;
|
||||
useSystemTheme: boolean;
|
||||
@@ -101,6 +123,8 @@ export interface Settings {
|
||||
warnOnUnverifiedDevices: boolean;
|
||||
|
||||
pauseAnimations: boolean;
|
||||
|
||||
composerToolbarButtons: ComposerToolbarSettings;
|
||||
}
|
||||
|
||||
const defaultSettings: Settings = {
|
||||
@@ -166,13 +190,23 @@ const defaultSettings: Settings = {
|
||||
warnOnUnverifiedDevices: false,
|
||||
|
||||
pauseAnimations: false,
|
||||
|
||||
composerToolbarButtons: DEFAULT_COMPOSER_TOOLBAR,
|
||||
};
|
||||
|
||||
export const getSettings = (): Settings => {
|
||||
try {
|
||||
const settings = localStorage.getItem(STORAGE_KEY);
|
||||
if (settings === null) return defaultSettings;
|
||||
return { ...defaultSettings, ...(JSON.parse(settings) as Settings) };
|
||||
const saved = JSON.parse(settings) as Partial<Settings>;
|
||||
return {
|
||||
...defaultSettings,
|
||||
...saved,
|
||||
composerToolbarButtons: {
|
||||
...DEFAULT_COMPOSER_TOOLBAR,
|
||||
...(saved.composerToolbarButtons ?? {}),
|
||||
},
|
||||
};
|
||||
} catch {
|
||||
localStorage.removeItem(STORAGE_KEY);
|
||||
return defaultSettings;
|
||||
|
||||
Reference in New Issue
Block a user