Conform more of the codebase to strictNullChecks (#10800)
This commit is contained in:
parent
adb29b38a3
commit
456c66db5b
46 changed files with 147 additions and 123 deletions
|
@ -47,7 +47,11 @@ export interface IWidgetEvent {
|
|||
sender: string;
|
||||
// eslint-disable-next-line camelcase
|
||||
state_key: string;
|
||||
content: Partial<IApp>;
|
||||
content: IApp;
|
||||
}
|
||||
|
||||
export interface UserWidget extends Omit<IWidgetEvent, "content"> {
|
||||
content: IWidget & Partial<IApp>;
|
||||
}
|
||||
|
||||
export default class WidgetUtils {
|
||||
|
@ -254,6 +258,7 @@ export default class WidgetUtils {
|
|||
const userId = client.getSafeUserId();
|
||||
|
||||
const content = {
|
||||
id: widgetId,
|
||||
type: widgetType.preferred,
|
||||
url: widgetUrl,
|
||||
name: widgetName,
|
||||
|
@ -354,7 +359,7 @@ export default class WidgetUtils {
|
|||
* Get user specific widgets (not linked to a specific room)
|
||||
* @return {object} Event content object containing current / active user widgets
|
||||
*/
|
||||
public static getUserWidgets(): Record<string, IWidgetEvent> {
|
||||
public static getUserWidgets(): Record<string, UserWidget> {
|
||||
const client = MatrixClientPeg.get();
|
||||
if (!client) {
|
||||
throw new Error("User not logged in");
|
||||
|
@ -370,7 +375,7 @@ export default class WidgetUtils {
|
|||
* Get user specific widgets (not linked to a specific room) as an array
|
||||
* @return {[object]} Array containing current / active user widgets
|
||||
*/
|
||||
public static getUserWidgetsArray(): IWidgetEvent[] {
|
||||
public static getUserWidgetsArray(): UserWidget[] {
|
||||
return Object.values(WidgetUtils.getUserWidgets());
|
||||
}
|
||||
|
||||
|
@ -378,18 +383,18 @@ export default class WidgetUtils {
|
|||
* Get active stickerpicker widgets (stickerpickers are user widgets by nature)
|
||||
* @return {[object]} Array containing current / active stickerpicker widgets
|
||||
*/
|
||||
public static getStickerpickerWidgets(): IWidgetEvent[] {
|
||||
public static getStickerpickerWidgets(): UserWidget[] {
|
||||
const widgets = WidgetUtils.getUserWidgetsArray();
|
||||
return widgets.filter((widget) => widget.content && widget.content.type === "m.stickerpicker");
|
||||
return widgets.filter((widget) => widget.content?.type === "m.stickerpicker");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all integration manager widgets for this user.
|
||||
* @returns {Object[]} An array of integration manager user widgets.
|
||||
*/
|
||||
public static getIntegrationManagerWidgets(): IWidgetEvent[] {
|
||||
public static getIntegrationManagerWidgets(): UserWidget[] {
|
||||
const widgets = WidgetUtils.getUserWidgetsArray();
|
||||
return widgets.filter((w) => w.content && w.content.type === "m.integration_manager");
|
||||
return widgets.filter((w) => w.content?.type === "m.integration_manager");
|
||||
}
|
||||
|
||||
public static getRoomWidgetsOfType(room: Room, type: WidgetType): MatrixEvent[] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue