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

Commit

Permalink
Apply strictNullChecks to src/components/views/rooms/wysiwyg_composer…
Browse files Browse the repository at this point in the history
…/* (#10653)

* update components folder

* update useInitialContent
  • Loading branch information
alunturner committed May 5, 2023
1 parent fbf3de5 commit c824c4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React, { MouseEventHandler } from "react";
import React from "react";

import { _t } from "../../../../../languageHandler";
import AccessibleButton from "../../../elements/AccessibleButton";
import AccessibleButton, { ButtonEvent } from "../../../elements/AccessibleButton";

interface EditionButtonsProps {
onCancelClick: MouseEventHandler<HTMLButtonElement>;
onSaveClick: MouseEventHandler<HTMLButtonElement>;
onCancelClick: (e: ButtonEvent) => void;
onSaveClick: (e: ButtonEvent) => void;
isSaveDisabled?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ export function parseEditorStateTransfer(
): string {
const partCreator = new CommandPartCreator(room, mxClient);

let parts: Part[];
let parts: (Part | undefined)[] = [];
if (editorStateTransfer.hasEditorState()) {
// if restoring state from a previous editor,
// restore serialized parts from the state
parts = editorStateTransfer.getSerializedParts().map((p) => partCreator.deserializePart(p));
const serializedParts = editorStateTransfer.getSerializedParts();
if (serializedParts !== null) {
parts = serializedParts.map((p) => partCreator.deserializePart(p));
}
} else {
// otherwise, either restore serialized parts from localStorage or parse the body of the event
// TODO local storage
Expand All @@ -59,7 +62,7 @@ export function parseEditorStateTransfer(
});
}

return parts.reduce((content, part) => content + part.text, "");
return parts.reduce((content, part) => content + part?.text, "");
// Todo local storage
// this.saveStoredEditorState();
}
Expand Down

0 comments on commit c824c4a

Please sign in to comment.