mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
web/types: split standard matrix types to separate file
This commit is contained in:
parent
dd6c7b4822
commit
3065f7363c
14 changed files with 106 additions and 60 deletions
|
@ -18,8 +18,9 @@ import type {
|
|||
EventRowID,
|
||||
EventType,
|
||||
RoomID,
|
||||
} from "./types/hitypes.ts"
|
||||
import type { ClientState, RPCEvent } from "./types/hievents.ts"
|
||||
ClientState,
|
||||
RPCEvent,
|
||||
} from "./types"
|
||||
import type RPCClient from "./rpc.ts"
|
||||
import { StateStore } from "./statestore.ts"
|
||||
|
||||
|
|
|
@ -23,9 +23,11 @@ import type {
|
|||
EventType,
|
||||
PaginationResponse,
|
||||
RoomID,
|
||||
TimelineRowID, UserID,
|
||||
} from "./types/hitypes.ts"
|
||||
import { RPCCommand, RPCEvent } from "./types/hievents.ts"
|
||||
TimelineRowID,
|
||||
UserID,
|
||||
RPCCommand,
|
||||
RPCEvent,
|
||||
} from "./types"
|
||||
|
||||
export interface ConnectionEvent {
|
||||
connected: boolean
|
||||
|
|
|
@ -25,8 +25,10 @@ import type {
|
|||
LazyLoadSummary,
|
||||
RoomID,
|
||||
TimelineRowTuple,
|
||||
} from "./types/hitypes.ts"
|
||||
import type { EventsDecryptedData, SyncCompleteData, SyncRoom } from "./types/hievents.ts"
|
||||
EventsDecryptedData,
|
||||
SyncCompleteData,
|
||||
SyncRoom,
|
||||
} from "./types"
|
||||
|
||||
function arraysAreEqual<T>(arr1?: T[], arr2?: T[]): boolean {
|
||||
if (!arr1 || !arr2) {
|
||||
|
|
|
@ -14,14 +14,16 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import {
|
||||
DBEvent,
|
||||
DBRoom,
|
||||
DeviceID,
|
||||
EventRowID,
|
||||
EventType,
|
||||
RoomID,
|
||||
TimelineRowTuple,
|
||||
UserID,
|
||||
} from "./mxtypes.ts"
|
||||
import {
|
||||
DBEvent,
|
||||
DBRoom,
|
||||
EventRowID,
|
||||
TimelineRowTuple,
|
||||
} from "./hitypes.ts"
|
||||
|
||||
export interface RPCCommand<T> {
|
||||
|
|
|
@ -13,18 +13,22 @@
|
|||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import {
|
||||
ContentURI,
|
||||
CreateEventContent,
|
||||
EncryptedEventContent,
|
||||
EncryptionEventContent,
|
||||
EventID,
|
||||
EventType,
|
||||
LazyLoadSummary,
|
||||
RelationType,
|
||||
RoomAlias,
|
||||
RoomID,
|
||||
UserID,
|
||||
} from "./mxtypes.ts"
|
||||
|
||||
export type EventRowID = number
|
||||
export type TimelineRowID = number
|
||||
export type RoomID = string
|
||||
export type EventID = string
|
||||
export type UserID = string
|
||||
export type DeviceID = string
|
||||
export type EventType = string
|
||||
export type ContentURI = string
|
||||
export type RoomAlias = string
|
||||
export type RoomVersion = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11"
|
||||
export type RoomType = "" | "m.space"
|
||||
export type RelationType = "m.annotation" | "m.reference" | "m.replace" | "m.thread"
|
||||
|
||||
export interface TimelineRowTuple {
|
||||
timeline_rowid: TimelineRowID
|
||||
|
@ -38,30 +42,6 @@ export enum RoomNameQuality {
|
|||
Explicit,
|
||||
}
|
||||
|
||||
export interface RoomPredecessor {
|
||||
room_id: RoomID
|
||||
event_id: EventID
|
||||
}
|
||||
|
||||
export interface CreateEventContent {
|
||||
type: RoomType
|
||||
"m.federate": boolean
|
||||
room_version: RoomVersion
|
||||
predecessor: RoomPredecessor
|
||||
}
|
||||
|
||||
export interface LazyLoadSummary {
|
||||
heroes?: UserID[]
|
||||
"m.joined_member_count"?: number
|
||||
"m.invited_member_count"?: number
|
||||
}
|
||||
|
||||
export interface EncryptionEventContent {
|
||||
algorithm: string
|
||||
rotation_period_ms?: number
|
||||
rotation_period_msgs?: number
|
||||
}
|
||||
|
||||
export interface DBRoom {
|
||||
room_id: RoomID
|
||||
creation_content: CreateEventContent
|
||||
|
@ -82,14 +62,6 @@ export interface DBRoom {
|
|||
prev_batch: string
|
||||
}
|
||||
|
||||
export interface EncryptedEventContent {
|
||||
algorithm: "m.megolm.v1.aes-sha2"
|
||||
ciphertext: string
|
||||
session_id: string
|
||||
sender_key?: string
|
||||
device_id?: DeviceID
|
||||
}
|
||||
|
||||
export interface DBEvent {
|
||||
rowid: EventRowID
|
||||
timeline_rowid: TimelineRowID
|
||||
|
|
3
web/src/api/types/index.ts
Normal file
3
web/src/api/types/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export * from "./mxtypes.ts"
|
||||
export * from "./hitypes.ts"
|
||||
export * from "./hievents.ts"
|
64
web/src/api/types/mxtypes.ts
Normal file
64
web/src/api/types/mxtypes.ts
Normal file
|
@ -0,0 +1,64 @@
|
|||
// gomuks - A Matrix client written in Go.
|
||||
// Copyright (C) 2024 Tulir Asokan
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
export type RoomID = string
|
||||
export type EventID = string
|
||||
export type UserID = string
|
||||
export type DeviceID = string
|
||||
export type EventType = string
|
||||
export type ContentURI = string
|
||||
export type RoomAlias = string
|
||||
export type RoomVersion = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11"
|
||||
export type RoomType = "" | "m.space"
|
||||
export type RelationType = "m.annotation" | "m.reference" | "m.replace" | "m.thread"
|
||||
|
||||
export interface RoomPredecessor {
|
||||
room_id: RoomID
|
||||
event_id: EventID
|
||||
}
|
||||
|
||||
export interface CreateEventContent {
|
||||
type: RoomType
|
||||
"m.federate": boolean
|
||||
room_version: RoomVersion
|
||||
predecessor: RoomPredecessor
|
||||
}
|
||||
|
||||
export interface LazyLoadSummary {
|
||||
heroes?: UserID[]
|
||||
"m.joined_member_count"?: number
|
||||
"m.invited_member_count"?: number
|
||||
}
|
||||
|
||||
export interface EncryptionEventContent {
|
||||
algorithm: string
|
||||
rotation_period_ms?: number
|
||||
rotation_period_msgs?: number
|
||||
}
|
||||
|
||||
export interface EncryptedEventContent {
|
||||
algorithm: "m.megolm.v1.aes-sha2"
|
||||
ciphertext: string
|
||||
session_id: string
|
||||
sender_key?: string
|
||||
device_id?: DeviceID
|
||||
}
|
||||
|
||||
export interface MemberEventContent {
|
||||
membership: "join" | "leave" | "ban" | "invite" | "knock"
|
||||
displayname?: string
|
||||
avatar_url?: ContentURI
|
||||
reason?: string
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import type { RPCCommand } from "./types/hievents.ts"
|
||||
import type { RPCCommand } from "./types"
|
||||
import RPCClient from "./rpc.ts"
|
||||
|
||||
export default class WSClient extends RPCClient {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import { useState, use } from "react"
|
||||
import type { RoomID } from "../api/types/hitypes.ts"
|
||||
import type { RoomID } from "../api/types"
|
||||
import RoomList from "./roomlist/RoomList.tsx"
|
||||
import RoomView from "./RoomView.tsx"
|
||||
import { ClientContext } from "./ClientContext.ts"
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import React, { useCallback, useEffect, useState } from "react"
|
||||
import type Client from "../../api/client.ts"
|
||||
import { ClientState } from "../../api/types"
|
||||
import "./LoginScreen.css"
|
||||
import { ClientState } from "../../api/types/hievents.ts"
|
||||
|
||||
export interface LoginScreenProps {
|
||||
client: Client
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import React, { useCallback, useState } from "react"
|
||||
import "./LoginScreen.css"
|
||||
import { LoginScreenProps } from "./LoginScreen.tsx"
|
||||
import "./LoginScreen.css"
|
||||
|
||||
export const VerificationScreen = ({ client, clientState }: LoginScreenProps) => {
|
||||
if (!clientState.is_logged_in) {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import React, { use, useMemo } from "react"
|
||||
import type { RoomID } from "../../api/types/hitypes.ts"
|
||||
import type { RoomID } from "../../api/types"
|
||||
import { useNonNullEventAsState } from "../../util/eventdispatcher.ts"
|
||||
import { ClientContext } from "../ClientContext.ts"
|
||||
import Entry from "./Entry.tsx"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import React from "react"
|
||||
import { RoomStateStore } from "../../api/statestore.ts"
|
||||
import { DBEvent } from "../../api/types/hitypes.ts"
|
||||
import { DBEvent, MemberEventContent } from "../../api/types"
|
||||
import { EventContentProps } from "./content/props.ts"
|
||||
import HiddenEvent from "./content/HiddenEvent.tsx"
|
||||
import "./TimelineEvent.css"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import sanitizeHtml from "sanitize-html"
|
||||
import { ContentURI } from "../../../api/types/hitypes.ts"
|
||||
import { ContentURI } from "../../../api/types"
|
||||
import { getMediaURL } from "../../../api/media.ts"
|
||||
import { sanitizeHtmlParams } from "../../../util/html.ts"
|
||||
import { EventContentProps } from "./props.ts"
|
||||
|
|
Loading…
Add table
Reference in a new issue