refactor(settings): drop three orphan settings with no UI and strip them via a one-shot migration
This commit is contained in:
parent
8fcb94e956
commit
06afe034c5
4 changed files with 29 additions and 13 deletions
|
|
@ -564,9 +564,12 @@ export function RoomTimeline({
|
|||
const [hideNickAvatarEvents] = useSetting(settingsAtom, 'hideNickAvatarEvents');
|
||||
const [mediaAutoLoad] = useSetting(settingsAtom, 'mediaAutoLoad');
|
||||
const [urlPreview] = useSetting(settingsAtom, 'urlPreview');
|
||||
const [encUrlPreview] = useSetting(settingsAtom, 'encUrlPreview');
|
||||
const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview;
|
||||
const [showHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents');
|
||||
// Encrypted rooms never auto-preview URLs (privacy-safe default; the
|
||||
// `encUrlPreview` opt-in setting was removed). Plaintext rooms honour urlPreview.
|
||||
const showUrlPreview = room.hasEncryptionStateEvent() ? false : urlPreview;
|
||||
// Hidden/redacted "dev view" of events — was an orphan setting with no UI,
|
||||
// permanently off. Pinned false; the hidden-event renderers below stay inert.
|
||||
const showHiddenEvents = false;
|
||||
const [showDeveloperTools] = useSetting(settingsAtom, 'developerTools');
|
||||
|
||||
const ignoredUsersList = useIgnoredUsers();
|
||||
|
|
|
|||
|
|
@ -306,9 +306,9 @@ export function ThreadDrawer({
|
|||
const useAuthentication = useMediaAuthentication();
|
||||
const [mediaAutoLoad] = useSetting(settingsAtom, 'mediaAutoLoad');
|
||||
const [urlPreview] = useSetting(settingsAtom, 'urlPreview');
|
||||
const [encUrlPreview] = useSetting(settingsAtom, 'encUrlPreview');
|
||||
const [hideActivity] = useSetting(settingsAtom, 'hideActivity');
|
||||
const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview;
|
||||
// Encrypted rooms never auto-preview URLs (the `encUrlPreview` opt-in was removed).
|
||||
const showUrlPreview = room.hasEncryptionStateEvent() ? false : urlPreview;
|
||||
|
||||
const unreadThreadingEnabled = useUnreadThreadingEnabled();
|
||||
|
||||
|
|
|
|||
|
|
@ -68,9 +68,10 @@ export const MessageEditor = as<'div', MessageEditorProps>(
|
|||
const mx = useMatrixClient();
|
||||
const editor = useEditor();
|
||||
const [enterForNewline] = useSetting(settingsAtom, 'enterForNewline');
|
||||
const [globalToolbar] = useSetting(settingsAtom, 'editorToolbar');
|
||||
const [isMarkdown] = useSetting(settingsAtom, 'isMarkdown');
|
||||
const [toolbar, setToolbar] = useState(globalToolbar);
|
||||
// The edit toolbar starts collapsed (the `editorToolbar` opt-in setting was
|
||||
// removed — it only ever gated this one initial-open flag).
|
||||
const [toolbar, setToolbar] = useState(false);
|
||||
const isComposing = useComposingCheck();
|
||||
|
||||
const [autocompleteQuery, setAutocompleteQuery] =
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ export interface Settings {
|
|||
themeId?: ThemeId;
|
||||
useSystemTheme: boolean;
|
||||
isMarkdown: boolean;
|
||||
editorToolbar: boolean;
|
||||
twitterEmoji: boolean;
|
||||
pageZoom: number;
|
||||
hideActivity: boolean;
|
||||
|
|
@ -20,8 +19,6 @@ export interface Settings {
|
|||
hideNickAvatarEvents: boolean;
|
||||
mediaAutoLoad: boolean;
|
||||
urlPreview: boolean;
|
||||
encUrlPreview: boolean;
|
||||
showHiddenEvents: boolean;
|
||||
|
||||
isNotificationSounds: boolean;
|
||||
inviteSpamFilter: boolean;
|
||||
|
|
@ -34,12 +31,12 @@ export interface Settings {
|
|||
const DAWN_MIGRATION_KEY = 'dawn-redesign-v1';
|
||||
const P3C_CLEANUP_KEY = 'dawn-p3c-cleanup';
|
||||
const SYSTEM_TIME_FORMAT_CLEANUP_KEY = 'system-time-format-cleanup';
|
||||
const ORPHAN_SETTINGS_CLEANUP_KEY = 'dawn-orphan-settings-cleanup';
|
||||
|
||||
const defaultSettings: Settings = {
|
||||
themeId: undefined,
|
||||
useSystemTheme: true,
|
||||
isMarkdown: true,
|
||||
editorToolbar: false,
|
||||
twitterEmoji: false,
|
||||
pageZoom: 100,
|
||||
hideActivity: false,
|
||||
|
|
@ -51,8 +48,6 @@ const defaultSettings: Settings = {
|
|||
hideNickAvatarEvents: true,
|
||||
mediaAutoLoad: true,
|
||||
urlPreview: true,
|
||||
encUrlPreview: false,
|
||||
showHiddenEvents: false,
|
||||
|
||||
isNotificationSounds: true,
|
||||
inviteSpamFilter: true,
|
||||
|
|
@ -125,6 +120,23 @@ export const getSettings = (): Settings => {
|
|||
setSettings(merged);
|
||||
}
|
||||
|
||||
// Dawn remnant sweep: strip the three orphan settings that had no UI toggle
|
||||
// and were frozen at their defaults forever — `editorToolbar` (only ever
|
||||
// pre-opened the edit overlay's toolbar), `encUrlPreview` (encrypted rooms now
|
||||
// never auto-preview, privacy-safe) and `showHiddenEvents` (the dev-only hidden
|
||||
// -event view, permanently off). One-shot strip of the stale persisted keys.
|
||||
if (!merged.migrationsApplied?.[ORPHAN_SETTINGS_CLEANUP_KEY]) {
|
||||
const orphan = merged as unknown as Record<string, unknown>;
|
||||
delete orphan.editorToolbar;
|
||||
delete orphan.encUrlPreview;
|
||||
delete orphan.showHiddenEvents;
|
||||
merged.migrationsApplied = {
|
||||
...(merged.migrationsApplied ?? {}),
|
||||
[ORPHAN_SETTINGS_CLEANUP_KEY]: true,
|
||||
};
|
||||
setSettings(merged);
|
||||
}
|
||||
|
||||
return merged;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue