Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make trailing : into a setting #6711

Merged
merged 7 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
'MessageComposerInput.ctrlEnterToSend',
'MessageComposerInput.surroundWith',
'MessageComposerInput.showStickersButton',
'MessageComposerInput.insertTrailingComma',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do have concerns about settings proliferating and causing maintenance burden.

-- @turt2live, #6711 (review)

This feels like something we should just be opinionated on and avoid adding a setting. Convention over configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it were up to me, I would just remove this feature but I know some people care about having it quite a lot and therefore I've made it into a setting

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MadLittleMods see element-hq/element-web#16682 for more context, there was some contention over this, and i think a good compromise to get this working at least one way or another is to make it into a setting, thus this PR.

];

static TIME_SETTINGS = [
Expand Down
5 changes: 4 additions & 1 deletion src/editor/parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { unicodeToShortcode } from "../HtmlUtils";
import * as Avatar from "../Avatar";
import defaultDispatcher from "../dispatcher/dispatcher";
import { Action } from "../dispatcher/actions";
import SettingsStore from "../settings/SettingsStore";

interface ISerializedPart {
type: Type.Plain | Type.Newline | Type.Emoji | Type.Command | Type.PillCandidate;
Expand Down Expand Up @@ -650,7 +651,9 @@ export class PartCreator {
userId: string,
): [UserPillPart, PlainPart] {
const pill = this.userPill(displayName, userId);
const postfix = this.plain(insertTrailingCharacter ? ": " : " ");
const postfix = this.plain(
insertTrailingCharacter && SettingsStore.getValue("MessageComposerInput.insertTrailingComma") ? ": " : " ",
turt2live marked this conversation as resolved.
Show resolved Hide resolved
);
return [pill, postfix];
}
}
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@
"Use custom size": "Use custom size",
"Enable Emoji suggestions while typing": "Enable Emoji suggestions while typing",
"Show stickers button": "Show stickers button",
"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",
"Use a more compact 'Modern' layout": "Use a more compact 'Modern' layout",
"Show a placeholder for removed messages": "Show a placeholder for removed messages",
"Show join/leave messages (invites/removes/bans unaffected)": "Show join/leave messages (invites/removes/bans unaffected)",
Expand Down
5 changes: 5 additions & 0 deletions src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ export const SETTINGS: {[setting: string]: ISetting} = {
default: true,
controller: new UIFeatureController(UIFeature.Widgets, false),
},
"MessageComposerInput.insertTrailingComma": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td('Insert a trailing colon after user mentions at the start of a message'),
default: true,
},
// TODO: Wire up appropriately to UI (FTUE notifications)
"Notifications.alwaysShowBadgeCounts": {
supportedLevels: LEVELS_ROOM_OR_ACCOUNT,
Expand Down
13 changes: 13 additions & 0 deletions src/settings/handlers/AccountSettingsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
return content[settingName];
}

if (settingName === "MessageComposerInput.insertTrailingComma") {
const content = this.getSettings() || {};
const value = content[settingName];
if (value === null || value === undefined) {
// Write true as it is the default. This will give us the option
// of making this opt-in in the future, without affecting old
// users
this.setValue(settingName, roomId, true);
return true;
}
return value;
}

const settings = this.getSettings() || {};
let preferredValue = settings[settingName];

Expand Down