Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 4c05b7d

Browse files
Make trailing : into a setting (#6711)
* Make trailing `:` into a setting Signed-off-by: Šimon Brandner <[email protected]> * Make traling comma opt-out Signed-off-by: Šimon Brandner <[email protected]> * Write `insertTrailingComma` when reading for future opt-in setting Signed-off-by: Šimon Brandner <[email protected]> * Update src/editor/parts.ts * Fix line length Signed-off-by: Šimon Brandner <[email protected]> Co-authored-by: Travis Ralston <[email protected]>
1 parent afbe3d1 commit 4c05b7d

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
162162
'MessageComposerInput.ctrlEnterToSend',
163163
'MessageComposerInput.surroundWith',
164164
'MessageComposerInput.showStickersButton',
165+
'MessageComposerInput.insertTrailingComma',
165166
];
166167

167168
static TIME_SETTINGS = [

src/editor/parts.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { unicodeToShortcode } from "../HtmlUtils";
3030
import * as Avatar from "../Avatar";
3131
import defaultDispatcher from "../dispatcher/dispatcher";
3232
import { Action } from "../dispatcher/actions";
33+
import SettingsStore from "../settings/SettingsStore";
3334

3435
interface ISerializedPart {
3536
type: Type.Plain | Type.Newline | Type.Emoji | Type.Command | Type.PillCandidate;
@@ -650,7 +651,10 @@ export class PartCreator {
650651
userId: string,
651652
): [UserPillPart, PlainPart] {
652653
const pill = this.userPill(displayName, userId);
653-
const postfix = this.plain(insertTrailingCharacter ? ": " : " ");
654+
const postfix = this.plain(
655+
insertTrailingCharacter &&
656+
(SettingsStore.getValue("MessageComposerInput.insertTrailingComma") ? ": " : " "),
657+
);
654658
return [pill, postfix];
655659
}
656660
}

src/i18n/strings/en_EN.json

+1
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@
906906
"Use custom size": "Use custom size",
907907
"Enable Emoji suggestions while typing": "Enable Emoji suggestions while typing",
908908
"Show stickers button": "Show stickers button",
909+
"Insert a trailing colon after user mentions at the start of a message": "Insert a trailing colon after user mentions at the start of a message",
909910
"Use a more compact 'Modern' layout": "Use a more compact 'Modern' layout",
910911
"Show a placeholder for removed messages": "Show a placeholder for removed messages",
911912
"Show join/leave messages (invites/removes/bans unaffected)": "Show join/leave messages (invites/removes/bans unaffected)",

src/settings/Settings.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ export const SETTINGS: {[setting: string]: ISetting} = {
429429
default: true,
430430
controller: new UIFeatureController(UIFeature.Widgets, false),
431431
},
432+
"MessageComposerInput.insertTrailingComma": {
433+
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
434+
displayName: _td('Insert a trailing colon after user mentions at the start of a message'),
435+
default: true,
436+
},
432437
// TODO: Wire up appropriately to UI (FTUE notifications)
433438
"Notifications.alwaysShowBadgeCounts": {
434439
supportedLevels: LEVELS_ROOM_OR_ACCOUNT,

src/settings/handlers/AccountSettingsHandler.ts

+13
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
121121
return content[settingName];
122122
}
123123

124+
if (settingName === "MessageComposerInput.insertTrailingComma") {
125+
const content = this.getSettings() || {};
126+
const value = content[settingName];
127+
if (value === null || value === undefined) {
128+
// Write true as it is the default. This will give us the option
129+
// of making this opt-in in the future, without affecting old
130+
// users
131+
this.setValue(settingName, roomId, true);
132+
return true;
133+
}
134+
return value;
135+
}
136+
124137
const settings = this.getSettings() || {};
125138
let preferredValue = settings[settingName];
126139

0 commit comments

Comments
 (0)