How to use the m.room.name function in m

To help you get started, we’ve selected a few m examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matrix-org / synapse / syweb / webclient / room / room-controller.js View on Github external
editName: function() {
            if ($scope.name.isEditing) {
                console.log("Warning: Already editing name.");
                return;
            };

            var nameEvent = $scope.room.current_room_state.state_events['m.room.name'];
            if (nameEvent) {
                $scope.name.newNameText = nameEvent.content.name;
            }
            else {
                $scope.name.newNameText = "";
            }

            // Force focus to the input
            $timeout(function() {
                angular.element('.roomNameInput').focus(); 
            }, 0);

            $scope.name.isEditing = true;
        },
        updateName: function() {
github matrix-org / matrix-js-sdk / spec / unit / webstorage.spec.js View on Github external
var userId = "@alice:bar";
    var mockStorageApi;
    var batchNum = 3;
    // web storage api keys
    var prefix = "room_" + roomId + "_timeline_";
    var stateKeyName = "room_" + roomId + "_state";

    // stored state events
    var stateEventMap = {
        "m.room.member": {},
        "m.room.name": {}
    };
    stateEventMap["m.room.member"][userId] = utils.mkMembership(
        {user: userId, room: roomId, mship: "join"}
    );
    stateEventMap["m.room.name"][""] = utils.mkEvent(
        {user: userId, room: roomId, type: "m.room.name",
        content: {
            name: "foo"
        }}
    );

    beforeEach(function() {
        utils.beforeEach(this); // eslint-disable-line no-invalid-this
        mockStorageApi = new MockStorageApi();
        store = new WebStorageStore(mockStorageApi, batchNum);
        room = new Room(roomId);
    });

    describe("constructor", function() {
        it("should throw if the WebStorage API functions are missing", function() {
            expect(function() {
github matrix-org / matrix-js-sdk / spec / unit / webstorage.spec.js View on Github external
it("should reconstruct room state", function() {
            setItem(mockStorageApi, stateKeyName, {
                events: stateEventMap,
                pagination_token: "tok"
            });

            var storedRoom = store.getRoom(roomId);
            expect(
                storedRoom.currentState.getStateEvents("m.room.name", "").event
            ).toEqual(stateEventMap["m.room.name"][""]);
            expect(
                storedRoom.currentState.getStateEvents("m.room.member", userId).event
            ).toEqual(stateEventMap["m.room.member"][userId]);
        });
github matrix-org / matrix-js-sdk / spec / unit / webstorage.spec.js View on Github external
utils.mkEvent({
                    user: userId, room: roomId, type: "m.room.name", event: true,
                    content: {
                        name: "Room Name Here for updates"
                    }
                })
            ];
            room.currentState.setStateEvents(events);
            store.storeEvents(room, events, "atoken");

            var liveEvents = getItem(mockStorageApi, prefix + "live");
            expect(liveEvents.length).toEqual(1);
            expect(liveEvents[0]).toEqual(events[0].event);

            var stateEvents = getItem(mockStorageApi, stateKeyName);
            expect(stateEvents.events["m.room.name"][""]).toEqual(events[0].event);
        });
    });
github matrix-construct / construct / share / webapp / js / room / state.js View on Github external
room.state.summary = function(state)
{
	let members = state['m.room.member'];
	let is_join = (mxid) => maybe(() => members[mxid].content.membership == "join");

	let aliases = [];
	Object.each(state['m.room.aliases'], (state_key, event) =>
	{
		aliases = aliases.concat(event.content.aliases);
	});

	return {
		room_id: state['m.room.create'][''].room_id,
		name: state['m.room.name'][''].content.name,
		topic: state['m.room.topic'][''].content.topic,
		canonical_alias: state['m.room.canonical_alias'][''].content.alias,
		world_readable: state['m.room.history_visibility'][''].content.history_visibility == "world_readable",
		guest_can_join: state['m.room.guest_access'][''].content.guest_access == "can_join",
		num_joined_members: Array.count(Object.keys(members), is_join),
		aliases: aliases,
	};
};