mirror of
https://github.com/block/buzz.git
synced 2026-11-25 10:42:26 +00:00
fix(theme): snapshot pre-migration appearance for per-community carry-forward
The appearance-widening migration read the live global glass keys, which this feature now rewrites on every community switch, and gated the carry-forward on a single per-profile latch. A brand-new or unreachable community visited first therefore reset glassBackground/glassOpacity/prominentActiveTab to defaults and republished the loss, and the one-shot latch only ever carried settings forward into whichever community hydrated first. Capture the profile's pre-migration appearance once into a durable snapshot, before the first mount rewrites the global keys, and derive both the empty-scope and legacy-record fallbacks from that snapshot. Every community now inherits the same former glass and prominent-tab choices regardless of hydration order or relay reachability. Replaces the per-profile appearance-migrated latch. On mobile, defaultCommunityTheme and legacyPreference() were constructor-built with the appearance presence flags defaulting to true, so a pre-hydration edit serialized false/65/false over a real desktop record. Mark those two origins as carrying no desktop appearance opinion so they omit the desktop-only fields, matching how a three-field payload parses. Co-authored-by: kenny lopez <klopez4212@gmail.com> Reviewed-by: Mongo <mongo@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
@@ -158,6 +158,23 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
test('a fresh community default omits desktop-only appearance fields', () {
|
||||
// Regression: a pre-hydration mobile edit built from the default must not
|
||||
// publish false/65/false over a real desktop record on the relay.
|
||||
expect(defaultCommunityTheme.toJson(), {
|
||||
'version': 1,
|
||||
'theme': 'buzz',
|
||||
'accent': '#3b82f6',
|
||||
'followSystem': true,
|
||||
});
|
||||
expect(defaultCommunityTheme.copyWith(accent: '#ef4444').toJson(), {
|
||||
'version': 1,
|
||||
'theme': 'buzz',
|
||||
'accent': '#ef4444',
|
||||
'followSystem': true,
|
||||
});
|
||||
});
|
||||
|
||||
test('supported edits preserve appearance values mobile cannot render', () {
|
||||
const desktopPreference = CommunityThemePreference(
|
||||
theme: 'buzz',
|
||||
@@ -241,8 +258,16 @@ void main() {
|
||||
theme: 'dracula',
|
||||
accent: 'neutral',
|
||||
followSystem: false,
|
||||
// The legacy mobile theme carries no desktop appearance opinion, so it
|
||||
// must not serialize desktop-only defaults over a real desktop record.
|
||||
includesGlassBackground: false,
|
||||
includesGlassOpacity: false,
|
||||
includesProminentActiveTab: false,
|
||||
),
|
||||
);
|
||||
expect(preference.toJson(), isNot(contains('glassBackground')));
|
||||
expect(preference.toJson(), isNot(contains('glassOpacity')));
|
||||
expect(preference.toJson(), isNot(contains('prominentActiveTab')));
|
||||
expect(preference.mode, ThemeMode.dark);
|
||||
expect(legacyAccentWireValue(6), '#a855f7');
|
||||
expect(legacyAccentWireValue(7), '#6366f1');
|
||||
|
||||
@@ -227,8 +227,14 @@ void main() {
|
||||
theme: 'dracula',
|
||||
accent: '#3b82f6',
|
||||
followSystem: true,
|
||||
// A fresh-community edit carries no desktop appearance opinion, so it
|
||||
// must not serialize desktop-only fields over a real desktop record.
|
||||
includesGlassBackground: false,
|
||||
includesGlassOpacity: false,
|
||||
includesProminentActiveTab: false,
|
||||
);
|
||||
expect(container.read(communityThemeProvider), local);
|
||||
expect(local.toJson(), isNot(contains('glassBackground')));
|
||||
|
||||
session.emit(session.remoteEvent(theme: 'houston', id: 'remote-z'));
|
||||
expect(container.read(communityThemeProvider), local);
|
||||
|
||||
Reference in New Issue
Block a user