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

Convert LoggedInView to an ES6 PureComponent Class & TypeScript #4398

Merged
merged 6 commits into from
Apr 14, 2020

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented Apr 13, 2020

Might be sane to review commit-by-commit.

After this, a skin could implement a single-room-app for embedding in an iframe using something like:

import * as React from "react";

import LoggedInView from "matrix-react-sdk/src/components/structures/LoggedInView";
import * as sdk from 'matrix-react-sdk/src/index';
import dis from 'matrix-react-sdk/src/dispatcher';
import SettingsStore, {SettingLevel} from "matrix-react-sdk/src/settings/SettingsStore";
import MatrixClientContext from "matrix-react-sdk/src/contexts/MatrixClientContext";

class SingleRoomLoggedInView extends LoggedInView {
    static replaces = "LoggedInView";
    static displayName = "SingleRoomLoggedInView";

    constructor(props, context) {
        super(props, context);

        SettingsStore.setValue("showReadReceipts", null, SettingLevel.DEVICE, false);

        dis.dispatch({
            action: 'view_room',
            room_id: "!OGEhHVWSdvArJzumhm:matrix.org",
        });
    }

    render() {
        const RoomView = sdk.getComponent('structures.RoomView');

        return (
            <MatrixClientContext.Provider value={this._matrixClient}>
                <div
                    onPaste={this._onPaste}
                    onKeyDown={this._onReactKeyDown}
                    className='mx_MatrixChat_wrapper'
                    aria-hidden={this.props.hideToSRUsers}
                    onMouseDown={this._onMouseDown}
                    onMouseUp={this._onMouseUp}
                >
                    <div className="mx_MatrixChat mx_MatrixChat_useCompactLayout">
                        <RoomView
                            ref={this._roomView}
                            autoJoin={true}
                            onRegistered={this.props.onRegistered}
                            viaServers={this.props.viaServers}
                            eventPixelOffset={this.props.initialEventPixelOffset}
                            disabled={this.props.middleDisabled}
                            resizeNotifier={this.props.resizeNotifier}
                        />
                    </div>
                </div>
            </MatrixClientContext.Provider>
        );
    }
}

export default SingleRoomLoggedInView;

@t3chguy t3chguy requested a review from a team April 13, 2020 13:33
Signed-off-by: Michael Telatynski <[email protected]>
Copy link
Contributor

@foldleft foldleft left a comment

Choose a reason for hiding this comment

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

Oh this is lovely :D

@turt2live
Copy link
Member

@replaceableComponent please

@t3chguy
Copy link
Member Author

t3chguy commented Apr 14, 2020

image
:(

t3chguy added 2 commits April 14, 2020 14:50
Signed-off-by: Michael Telatynski <[email protected]>
This reverts commit 50d6551

Signed-off-by: Michael Telatynski <[email protected]>
@t3chguy
Copy link
Member Author

t3chguy commented Apr 14, 2020

The decorator is incompatible with ts at this time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants