Respond to review
- remove all refs to getsdk - i18n - some lints
This commit is contained in:
parent
2fcf30c1ec
commit
69969dfee8
3 changed files with 39 additions and 37 deletions
|
@ -14,14 +14,13 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import * as Avatar from '../../../Avatar';
|
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
import { MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
||||||
import * as sdk from "../../../index";
|
|
||||||
|
import * as Avatar from '../../../Avatar';
|
||||||
|
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
||||||
|
import EventTile from '../rooms/EventTile';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
/**
|
/**
|
||||||
|
@ -42,8 +41,8 @@ interface IProps {
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
userId: string;
|
userId: string;
|
||||||
displayname: string,
|
displayname: string;
|
||||||
avatar_url: string,
|
avatar_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AVATAR_SIZE = 32;
|
const AVATAR_SIZE = 32;
|
||||||
|
@ -62,7 +61,8 @@ export default class MessagePreview extends React.Component<IProps, IState> {
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
// Fetch current user data
|
// Fetch current user data
|
||||||
const client = MatrixClientPeg.get()
|
const client = MatrixClientPeg.get()
|
||||||
const userId = await client.getUserId();
|
const userId = client.getUserId();
|
||||||
|
console.log({userId})
|
||||||
const profileInfo = await client.getProfileInfo(userId);
|
const profileInfo = await client.getProfileInfo(userId);
|
||||||
const avatar_url = Avatar.avatarUrlForUser(
|
const avatar_url = Avatar.avatarUrlForUser(
|
||||||
{avatarUrl: profileInfo.avatar_url},
|
{avatarUrl: profileInfo.avatar_url},
|
||||||
|
@ -76,24 +76,22 @@ export default class MessagePreview extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
private fakeEvent({userId, displayname, avatar_url}: IState) {
|
||||||
const EventTile = sdk.getComponent("views.rooms.EventTile");
|
|
||||||
|
|
||||||
// Fake it till we make it
|
// Fake it till we make it
|
||||||
const event = new MatrixEvent(JSON.parse(`{
|
const event = new MatrixEvent(JSON.parse(`{
|
||||||
"type": "m.room.message",
|
"type": "m.room.message",
|
||||||
"sender": "${this.state.userId}",
|
"sender": "${userId}",
|
||||||
"content": {
|
"content": {
|
||||||
"m.new_content": {
|
"m.new_content": {
|
||||||
"msgtype": "m.text",
|
"msgtype": "m.text",
|
||||||
"body": "${this.props.message}",
|
"body": "${this.props.message}",
|
||||||
"displayname": "${this.state.displayname}",
|
"displayname": "${displayname}",
|
||||||
"avatar_url": "${this.state.avatar_url}"
|
"avatar_url": "${avatar_url}"
|
||||||
},
|
},
|
||||||
"msgtype": "m.text",
|
"msgtype": "m.text",
|
||||||
"body": "${this.props.message}",
|
"body": "${this.props.message}",
|
||||||
"displayname": "${this.state.displayname}",
|
"displayname": "${displayname}",
|
||||||
"avatar_url": "${this.state.avatar_url}"
|
"avatar_url": "${avatar_url}"
|
||||||
},
|
},
|
||||||
"unsigned": {
|
"unsigned": {
|
||||||
"age": 97
|
"age": 97
|
||||||
|
@ -104,13 +102,19 @@ export default class MessagePreview extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
// Fake it more
|
// Fake it more
|
||||||
event.sender = {
|
event.sender = {
|
||||||
name: this.state.displayname,
|
name: displayname,
|
||||||
userId: this.state.userId,
|
userId: userId,
|
||||||
getAvatarUrl: (..._) => {
|
getAvatarUrl: (..._) => {
|
||||||
return this.state.avatar_url;
|
return avatar_url;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public render() {
|
||||||
|
const event = this.fakeEvent(this.state);
|
||||||
|
|
||||||
let className = classnames(
|
let className = classnames(
|
||||||
this.props.className,
|
this.props.className,
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,6 @@ limitations under the License.
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {_t} from "../../../../../languageHandler";
|
import {_t} from "../../../../../languageHandler";
|
||||||
import SettingsStore, {SettingLevel} from "../../../../../settings/SettingsStore";
|
import SettingsStore, {SettingLevel} from "../../../../../settings/SettingsStore";
|
||||||
import * as sdk from "../../../../../index";
|
|
||||||
import { enumerateThemes } from "../../../../../theme";
|
import { enumerateThemes } from "../../../../../theme";
|
||||||
import ThemeWatcher from "../../../../../settings/watchers/ThemeWatcher";
|
import ThemeWatcher from "../../../../../settings/watchers/ThemeWatcher";
|
||||||
import Field from "../../../elements/Field";
|
import Field from "../../../elements/Field";
|
||||||
|
@ -30,28 +29,32 @@ import { FontWatcher } from "../../../../../settings/watchers/FontWatcher";
|
||||||
import { RecheckThemePayload } from '../../../../../dispatcher/payloads/RecheckThemePayload';
|
import { RecheckThemePayload } from '../../../../../dispatcher/payloads/RecheckThemePayload';
|
||||||
import { Action } from '../../../../../dispatcher/actions';
|
import { Action } from '../../../../../dispatcher/actions';
|
||||||
import { IValidationResult, IFieldState } from '../../../elements/Validation';
|
import { IValidationResult, IFieldState } from '../../../elements/Validation';
|
||||||
|
import StyledRadioButton from '../../../elements/StyledRadioButton';
|
||||||
|
import StyledCheckbox from '../../../elements/StyledCheckbox';
|
||||||
|
import SettingsFlag from '../../../elements/SettingsFlag';
|
||||||
|
import MessagePreview from '../../../elements/MessagePreview';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IThemeState {
|
interface IThemeState {
|
||||||
theme: string,
|
theme: string;
|
||||||
useSystemTheme: boolean,
|
useSystemTheme: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CustomThemeMessage {
|
export interface CustomThemeMessage {
|
||||||
isError: boolean,
|
isError: boolean;
|
||||||
text: string
|
text: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IState extends IThemeState {
|
interface IState extends IThemeState {
|
||||||
// String displaying the current selected fontSize.
|
// String displaying the current selected fontSize.
|
||||||
// Needs to be string for things like '17.' without
|
// Needs to be string for things like '17.' without
|
||||||
// trailing 0s.
|
// trailing 0s.
|
||||||
fontSize: string,
|
fontSize: string;
|
||||||
customThemeUrl: string,
|
customThemeUrl: string;
|
||||||
customThemeMessage: CustomThemeMessage,
|
customThemeMessage: CustomThemeMessage;
|
||||||
useCustomFontSize: boolean,
|
useCustomFontSize: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class AppearanceUserSettingsTab extends React.Component<IProps, IState> {
|
export default class AppearanceUserSettingsTab extends React.Component<IProps, IState> {
|
||||||
|
@ -198,10 +201,6 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
|
||||||
};
|
};
|
||||||
|
|
||||||
private renderThemeSection() {
|
private renderThemeSection() {
|
||||||
const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag");
|
|
||||||
const StyledCheckbox = sdk.getComponent("views.elements.StyledCheckbox");
|
|
||||||
const StyledRadioButton = sdk.getComponent("views.elements.StyledRadioButton");
|
|
||||||
|
|
||||||
const themeWatcher = new ThemeWatcher();
|
const themeWatcher = new ThemeWatcher();
|
||||||
let systemThemeSection: JSX.Element;
|
let systemThemeSection: JSX.Element;
|
||||||
if (themeWatcher.isSystemThemeSupported()) {
|
if (themeWatcher.isSystemThemeSupported()) {
|
||||||
|
@ -279,15 +278,13 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderFontSection() {
|
private renderFontSection() {
|
||||||
const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag");
|
|
||||||
const MessagePreview = sdk.getComponent("views.elements.MessagePreview");
|
|
||||||
|
|
||||||
return <div className="mx_SettingsTab_section mx_AppearanceUserSettingsTab_fontScaling">
|
return <div className="mx_SettingsTab_section mx_AppearanceUserSettingsTab_fontScaling">
|
||||||
|
|
||||||
<span className="mx_SettingsTab_subheading">{_t("Font size")}</span>
|
<span className="mx_SettingsTab_subheading">{_t("Font size")}</span>
|
||||||
<MessagePreview
|
<MessagePreview
|
||||||
className="mx_AppearanceUserSettingsTab_fontSlider_preview"
|
className="mx_AppearanceUserSettingsTab_fontSlider_preview"
|
||||||
message="Hey you. You're the best!"
|
message={_t("Hey you. You're the best!")}
|
||||||
|
useIRCLayout={false}
|
||||||
/>
|
/>
|
||||||
<div className="mx_AppearanceUserSettingsTab_fontSlider">
|
<div className="mx_AppearanceUserSettingsTab_fontSlider">
|
||||||
<div className="mx_AppearanceUserSettingsTab_fontSlider_smallText">Aa</div>
|
<div className="mx_AppearanceUserSettingsTab_fontSlider_smallText">Aa</div>
|
||||||
|
|
|
@ -779,6 +779,7 @@
|
||||||
"Custom theme URL": "Custom theme URL",
|
"Custom theme URL": "Custom theme URL",
|
||||||
"Add theme": "Add theme",
|
"Add theme": "Add theme",
|
||||||
"Theme": "Theme",
|
"Theme": "Theme",
|
||||||
|
"Hey you. You're the best!": "Hey you. You're the best!",
|
||||||
"Customise your appearance": "Customise your appearance",
|
"Customise your appearance": "Customise your appearance",
|
||||||
"Appearance Settings only affect this Riot session.": "Appearance Settings only affect this Riot session.",
|
"Appearance Settings only affect this Riot session.": "Appearance Settings only affect this Riot session.",
|
||||||
"Flair": "Flair",
|
"Flair": "Flair",
|
||||||
|
|
Loading…
Reference in a new issue