Skip to content

Commit 8fccc58

Browse files
settings: Add an experimental flag to toggle rendering KaTeX
Following commits will add ability to render some basic KaTeX content, where rendering of some KaTeX content would be broken. So, add an experimental flag which is disabled by default, and allows the user or developer to explicitly enable and test the rendering of KaTeX content.
1 parent e5e00f7 commit 8fccc58

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/model/settings.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ enum BoolGlobalSetting {
110110
/// (Having one stable value in this enum is also handy for tests.)
111111
placeholderIgnore(GlobalSettingType.placeholder, false),
112112

113+
/// An experimental flag to toggle rendering KaTeX content in messages.
114+
renderKatex(GlobalSettingType.experimentalFeatureFlag, false),
115+
113116
// Former settings which might exist in the database,
114117
// whose names should therefore not be reused:
115118
// (this list is empty so far)

test/model/settings_test.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,42 +79,63 @@ void main() {
7979
final globalSettings = eg.globalStore(boolGlobalSettings: {}).settings;
8080
check(globalSettings).getBool(BoolGlobalSetting.placeholderIgnore)
8181
.isFalse();
82+
check(globalSettings).getBool(BoolGlobalSetting.renderKatex)
83+
.isFalse();
8284
assert(!BoolGlobalSetting.placeholderIgnore.default_);
85+
assert(!BoolGlobalSetting.renderKatex.default_);
8386
});
8487

8588
test('get from initial load', () {
8689
final globalSettings = eg.globalStore(boolGlobalSettings: {
8790
BoolGlobalSetting.placeholderIgnore: true,
91+
BoolGlobalSetting.renderKatex: true,
8892
}).settings;
8993
check(globalSettings).getBool(BoolGlobalSetting.placeholderIgnore)
9094
.isTrue();
95+
check(globalSettings).getBool(BoolGlobalSetting.renderKatex)
96+
.isTrue();
9197
});
9298

9399
test('set, get', () async {
94100
final globalSettings = eg.globalStore(boolGlobalSettings: {}).settings;
95101
check(globalSettings).getBool(BoolGlobalSetting.placeholderIgnore)
96102
.isFalse();
103+
check(globalSettings).getBool(BoolGlobalSetting.renderKatex)
104+
.isFalse();
97105

98106
await globalSettings.setBool(BoolGlobalSetting.placeholderIgnore, true);
107+
await globalSettings.setBool(BoolGlobalSetting.renderKatex, true);
99108
check(globalSettings).getBool(BoolGlobalSetting.placeholderIgnore)
100109
.isTrue();
110+
check(globalSettings).getBool(BoolGlobalSetting.renderKatex)
111+
.isTrue();
101112

102113
await globalSettings.setBool(BoolGlobalSetting.placeholderIgnore, false);
114+
await globalSettings.setBool(BoolGlobalSetting.renderKatex, false);
103115
check(globalSettings).getBool(BoolGlobalSetting.placeholderIgnore)
104116
.isFalse();
117+
check(globalSettings).getBool(BoolGlobalSetting.renderKatex)
118+
.isFalse();
105119
});
106120

107121
test('set to null -> revert to default', () async {
108122
final globalSettings = eg.globalStore(boolGlobalSettings: {
109123
BoolGlobalSetting.placeholderIgnore: true,
124+
BoolGlobalSetting.renderKatex: true,
110125
}).settings;
111126
check(globalSettings).getBool(BoolGlobalSetting.placeholderIgnore)
112127
.isTrue();
128+
check(globalSettings).getBool(BoolGlobalSetting.renderKatex)
129+
.isTrue();
113130

114131
await globalSettings.setBool(BoolGlobalSetting.placeholderIgnore, null);
132+
await globalSettings.setBool(BoolGlobalSetting.renderKatex, null);
115133
check(globalSettings).getBool(BoolGlobalSetting.placeholderIgnore)
116134
.isFalse();
135+
check(globalSettings).getBool(BoolGlobalSetting.renderKatex)
136+
.isFalse();
117137
assert(!BoolGlobalSetting.placeholderIgnore.default_);
138+
assert(!BoolGlobalSetting.renderKatex.default_);
118139
});
119140
});
120141
}

0 commit comments

Comments
 (0)