Add SettingsLevel enum; Move settings to own file.
Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@ limitations under the License.
|
||||
const React = require('react');
|
||||
const sdk = require("../../../index");
|
||||
import { _t, _tJsx } from '../../../languageHandler';
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
||||
|
||||
|
||||
module.exports = React.createClass({
|
||||
@@ -38,7 +38,7 @@ module.exports = React.createClass({
|
||||
const roomId = this.props.room.roomId;
|
||||
|
||||
let previewsForAccount = null;
|
||||
if (SettingsStore.getValueAt("account", "urlPreviewsEnabled")) {
|
||||
if (SettingsStore.getValueAt(SettingLevel.ACCOUNT, "urlPreviewsEnabled")) {
|
||||
previewsForAccount = (
|
||||
_tJsx("You have <a>enabled</a> URL previews by default.", /<a>(.*?)<\/a>/, (sub)=><a href="#/settings">{ sub }</a>)
|
||||
);
|
||||
@@ -54,14 +54,14 @@ module.exports = React.createClass({
|
||||
previewsForRoom = (
|
||||
<label>
|
||||
<SettingsFlag name="urlPreviewsEnabled"
|
||||
level="room"
|
||||
level={SettingLevel.ROOM}
|
||||
roomId={this.props.room.roomId}
|
||||
isExplicit={true} />
|
||||
</label>
|
||||
);
|
||||
} else {
|
||||
let str = "URL previews are enabled by default for participants in this room.";
|
||||
if (!SettingsStore.getValueAt("room", "urlPreviewsEnabled")) {
|
||||
if (!SettingsStore.getValueAt(SettingLevel.ROOM, "urlPreviewsEnabled")) {
|
||||
str = "URL previews are disabled by default for participants in this room.";
|
||||
}
|
||||
previewsForRoom = (<label>{ _t(str) }</label>);
|
||||
@@ -69,7 +69,7 @@ module.exports = React.createClass({
|
||||
|
||||
let previewsForRoomAccount = (
|
||||
<SettingsFlag name="urlPreviewsEnabled"
|
||||
level="room-account"
|
||||
level={SettingLevel.ROOM_ACCOUNT}
|
||||
roomId={this.props.room.roomId}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -22,7 +22,7 @@ import Modal from '../../../Modal';
|
||||
import sdk from '../../../index';
|
||||
import dis from '../../../dispatcher';
|
||||
import Autocomplete from './Autocomplete';
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
||||
|
||||
|
||||
export default class MessageComposer extends React.Component {
|
||||
@@ -226,7 +226,7 @@ export default class MessageComposer extends React.Component {
|
||||
}
|
||||
|
||||
onToggleFormattingClicked() {
|
||||
SettingsStore.setValue("MessageComposer.showFormatting", null, "account", !this.state.showFormatting);
|
||||
SettingsStore.setValue("MessageComposer.showFormatting", null, SettingLevel.DEVICE, !this.state.showFormatting);
|
||||
this.setState({showFormatting: !this.state.showFormatting});
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ const REGEX_MATRIXTO = new RegExp(MATRIXTO_URL_PATTERN);
|
||||
const REGEX_MATRIXTO_MARKDOWN_GLOBAL = new RegExp(MATRIXTO_MD_LINK_PATTERN, 'g');
|
||||
|
||||
import {asciiRegexp, shortnameToUnicode, emojioneList, asciiList, mapUnicodeToShort} from 'emojione';
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
||||
const EMOJI_SHORTNAMES = Object.keys(emojioneList);
|
||||
const EMOJI_UNICODE_TO_SHORTNAME = mapUnicodeToShort();
|
||||
const REGEX_EMOJI_WHITESPACE = new RegExp('(?:^|\\s)(' + asciiRegexp + ')\\s$');
|
||||
@@ -535,7 +535,7 @@ export default class MessageComposerInput extends React.Component {
|
||||
editorState: this.createEditorState(enabled, contentState),
|
||||
isRichtextEnabled: enabled,
|
||||
});
|
||||
SettingsStore.setValue("MessageComposerInput.isRichTextEnabled", null, "account", enabled);
|
||||
SettingsStore.setValue("MessageComposerInput.isRichTextEnabled", null, SettingLevel.ACCOUNT, enabled);
|
||||
}
|
||||
|
||||
handleKeyCommand = (command: string): boolean => {
|
||||
|
||||
@@ -24,7 +24,7 @@ import Modal from '../../../Modal';
|
||||
import ObjectUtils from '../../../ObjectUtils';
|
||||
import dis from '../../../dispatcher';
|
||||
import AccessibleButton from '../elements/AccessibleButton';
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
||||
|
||||
|
||||
// parse a string as an integer; if the input is undefined, or cannot be parsed
|
||||
@@ -382,7 +382,7 @@ module.exports = React.createClass({
|
||||
// TODO: {Travis} Use generic blacklistUnverifiedDevices
|
||||
const blacklistUnverifiedDevicesPerRoom = SettingsStore.getValue("blacklistUnverifiedDevicesPerRoom");
|
||||
blacklistUnverifiedDevicesPerRoom[this.props.room.roomId] = value;
|
||||
SettingsStore.setValue("blacklistUnverifiedDevicesPerRoom", null, "device", blacklistUnverifiedDevicesPerRoom);
|
||||
SettingsStore.setValue("blacklistUnverifiedDevicesPerRoom", null, SettingLevel.DEVICE, blacklistUnverifiedDevicesPerRoom);
|
||||
|
||||
this.props.room.setBlacklistUnverifiedDevices(value);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user