mirror of https://github.com/vector-im/riot-web
Appease the linter
parent
11068d189c
commit
3e4a721111
|
@ -42,7 +42,7 @@ export default class UserSettingsDialog extends React.Component {
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
mjolnirEnabled: SettingsStore.isFeatureEnabled("feature_mjolnir"),
|
mjolnirEnabled: SettingsStore.isFeatureEnabled("feature_mjolnir"),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount(): void {
|
componentDidMount(): void {
|
||||||
|
|
|
@ -88,7 +88,8 @@ module.exports = createReactClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SettingsStore.isFeatureEnabled("feature_mjolnir")) {
|
if (SettingsStore.isFeatureEnabled("feature_mjolnir")) {
|
||||||
const allowRender = localStorage.getItem(`mx_mjolnir_render_${this.props.mxEvent.getRoomId()}__${this.props.mxEvent.getId()}`) === "true";
|
const key = `mx_mjolnir_render_${this.props.mxEvent.getRoomId()}__${this.props.mxEvent.getId()}`;
|
||||||
|
const allowRender = localStorage.getItem(key) === "true";
|
||||||
|
|
||||||
if (!allowRender) {
|
if (!allowRender) {
|
||||||
const userDomain = this.props.mxEvent.getSender().split(':').slice(1).join(':');
|
const userDomain = this.props.mxEvent.getSender().split(':').slice(1).join(':');
|
||||||
|
|
|
@ -32,7 +32,8 @@ export default class MjolnirBody extends React.Component {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
localStorage.setItem(`mx_mjolnir_render_${this.props.mxEvent.getRoomId()}__${this.props.mxEvent.getId()}`, "true");
|
const key = `mx_mjolnir_render_${this.props.mxEvent.getRoomId()}__${this.props.mxEvent.getId()}`;
|
||||||
|
localStorage.setItem(key, "true");
|
||||||
this.props.onTileUpdate();
|
this.props.onTileUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,9 @@ export default class MjolnirUserSettingsTab extends React.Component {
|
||||||
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
||||||
|
|
||||||
const personalList = Mjolnir.sharedInstance().getPersonalList();
|
const personalList = Mjolnir.sharedInstance().getPersonalList();
|
||||||
const lists = Mjolnir.sharedInstance().lists.filter(b => personalList ? personalList.roomId !== b.roomId : true);
|
const lists = Mjolnir.sharedInstance().lists.filter(b => {
|
||||||
|
return personalList? personalList.roomId !== b.roomId : true;
|
||||||
|
});
|
||||||
if (!lists || lists.length <= 0) return <i>{_t("You are not subscribed to any lists")}</i>;
|
if (!lists || lists.length <= 0) return <i>{_t("You are not subscribed to any lists")}</i>;
|
||||||
|
|
||||||
const tiles = [];
|
const tiles = [];
|
||||||
|
@ -239,19 +241,19 @@ export default class MjolnirUserSettingsTab extends React.Component {
|
||||||
<div className="mx_SettingsTab_heading">{_t("Ignored users")}</div>
|
<div className="mx_SettingsTab_heading">{_t("Ignored users")}</div>
|
||||||
<div className="mx_SettingsTab_section">
|
<div className="mx_SettingsTab_section">
|
||||||
<div className='mx_SettingsTab_subsectionText'>
|
<div className='mx_SettingsTab_subsectionText'>
|
||||||
<span className='warning'>{_t("⚠ These settings are meant for advanced users.")}</span><br/>
|
<span className='warning'>{_t("⚠ These settings are meant for advanced users.")}</span><br />
|
||||||
<br/>
|
<br />
|
||||||
{_t(
|
{_t(
|
||||||
"Add users and servers you want to ignore here. Use asterisks " +
|
"Add users and servers you want to ignore here. Use asterisks " +
|
||||||
"to have Riot match any characters. For example, <code>@bot:*</code> " +
|
"to have Riot match any characters. For example, <code>@bot:*</code> " +
|
||||||
"would ignore all users that have the name 'bot' on any server.",
|
"would ignore all users that have the name 'bot' on any server.",
|
||||||
{}, {code: (s) => <code>{s}</code>},
|
{}, {code: (s) => <code>{s}</code>},
|
||||||
)}<br/>
|
)}<br />
|
||||||
<br/>
|
<br />
|
||||||
{_t(
|
{_t(
|
||||||
"Ignoring people is done through ban lists which contain rules for " +
|
"Ignoring people is done through ban lists which contain rules for " +
|
||||||
"who to ban. Subscribing to a ban list means the users/servers blocked by " +
|
"who to ban. Subscribing to a ban list means the users/servers blocked by " +
|
||||||
"that list will be hidden from you."
|
"that list will be hidden from you.",
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -29,9 +29,15 @@ export const SERVER_RULE_TYPES = [RULE_SERVER, "org.matrix.mjolnir.rule.server"]
|
||||||
export const ALL_RULE_TYPES = [...USER_RULE_TYPES, ...ROOM_RULE_TYPES, ...SERVER_RULE_TYPES];
|
export const ALL_RULE_TYPES = [...USER_RULE_TYPES, ...ROOM_RULE_TYPES, ...SERVER_RULE_TYPES];
|
||||||
|
|
||||||
export function ruleTypeToStable(rule: string, unstable = true): string {
|
export function ruleTypeToStable(rule: string, unstable = true): string {
|
||||||
if (USER_RULE_TYPES.includes(rule)) return unstable ? USER_RULE_TYPES[USER_RULE_TYPES.length - 1] : RULE_USER;
|
if (USER_RULE_TYPES.includes(rule)) {
|
||||||
if (ROOM_RULE_TYPES.includes(rule)) return unstable ? ROOM_RULE_TYPES[ROOM_RULE_TYPES.length - 1] : RULE_ROOM;
|
return unstable ? USER_RULE_TYPES[USER_RULE_TYPES.length - 1] : RULE_USER;
|
||||||
if (SERVER_RULE_TYPES.includes(rule)) return unstable ? SERVER_RULE_TYPES[SERVER_RULE_TYPES.length - 1] : RULE_SERVER;
|
}
|
||||||
|
if (ROOM_RULE_TYPES.includes(rule)) {
|
||||||
|
return unstable ? ROOM_RULE_TYPES[ROOM_RULE_TYPES.length - 1] : RULE_ROOM;
|
||||||
|
}
|
||||||
|
if (SERVER_RULE_TYPES.includes(rule)) {
|
||||||
|
return unstable ? SERVER_RULE_TYPES[SERVER_RULE_TYPES.length - 1] : RULE_SERVER;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,9 @@ export const RECOMMENDATION_BAN = "m.ban";
|
||||||
export const RECOMMENDATION_BAN_TYPES = [RECOMMENDATION_BAN, "org.matrix.mjolnir.ban"];
|
export const RECOMMENDATION_BAN_TYPES = [RECOMMENDATION_BAN, "org.matrix.mjolnir.ban"];
|
||||||
|
|
||||||
export function recommendationToStable(recommendation: string, unstable = true): string {
|
export function recommendationToStable(recommendation: string, unstable = true): string {
|
||||||
if (RECOMMENDATION_BAN_TYPES.includes(recommendation)) return unstable ? RECOMMENDATION_BAN_TYPES[RECOMMENDATION_BAN_TYPES.length - 1] : RECOMMENDATION_BAN;
|
if (RECOMMENDATION_BAN_TYPES.includes(recommendation)) {
|
||||||
|
return unstable ? RECOMMENDATION_BAN_TYPES[RECOMMENDATION_BAN_TYPES.length - 1] : RECOMMENDATION_BAN;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,11 +78,13 @@ export class Mjolnir {
|
||||||
const resp = await MatrixClientPeg.get().createRoom({
|
const resp = await MatrixClientPeg.get().createRoom({
|
||||||
name: _t("My Ban List"),
|
name: _t("My Ban List"),
|
||||||
topic: _t("This is your list of users/servers you have blocked - don't leave the room!"),
|
topic: _t("This is your list of users/servers you have blocked - don't leave the room!"),
|
||||||
preset: "private_chat"
|
preset: "private_chat",
|
||||||
});
|
});
|
||||||
personalRoomId = resp['room_id'];
|
personalRoomId = resp['room_id'];
|
||||||
await SettingsStore.setValue("mjolnirPersonalRoom", null, SettingLevel.ACCOUNT, personalRoomId);
|
await SettingsStore.setValue(
|
||||||
await SettingsStore.setValue("mjolnirRooms", null, SettingLevel.ACCOUNT, [personalRoomId, ...this._roomIds]);
|
"mjolnirPersonalRoom", null, SettingLevel.ACCOUNT, personalRoomId);
|
||||||
|
await SettingsStore.setValue(
|
||||||
|
"mjolnirRooms", null, SettingLevel.ACCOUNT, [personalRoomId, ...this._roomIds]);
|
||||||
}
|
}
|
||||||
if (!personalRoomId) {
|
if (!personalRoomId) {
|
||||||
throw new Error("Error finding a room ID to use");
|
throw new Error("Error finding a room ID to use");
|
||||||
|
|
|
@ -50,5 +50,4 @@ export class MatrixGlob {
|
||||||
test(val: string): boolean {
|
test(val: string): boolean {
|
||||||
return this._regex.test(val);
|
return this._regex.test(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue