forked from Mirrors/gomuks
web/all: reorganize files
This commit is contained in:
parent
243ba51002
commit
40b66f3057
22 changed files with 55 additions and 40 deletions
|
@ -14,14 +14,13 @@
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import { useEffect, useMemo, useState } from "react"
|
import { useEffect, useMemo, useState } from "react"
|
||||||
import "./App.css"
|
import Client from "./api/client.ts"
|
||||||
import Client from "./client.ts"
|
import WSClient from "./api/wsclient.ts"
|
||||||
import WSClient from "./wsclient.ts"
|
import { ClientState } from "./api/types/hievents.ts"
|
||||||
import { ClientState } from "./hievents.ts"
|
import { ConnectionEvent } from "./api/rpc.ts"
|
||||||
import { ConnectionEvent } from "./rpc.ts"
|
import { LoginScreen, VerificationScreen } from "./ui/login"
|
||||||
import { LoginScreen, VerificationScreen } from "./login"
|
|
||||||
import { ScaleLoader } from "react-spinners"
|
import { ScaleLoader } from "react-spinners"
|
||||||
import MainScreen from "./MainScreen.tsx"
|
import MainScreen from "./ui/MainScreen.tsx"
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [connState, setConnState] = useState<ConnectionEvent>()
|
const [connState, setConnState] = useState<ConnectionEvent>()
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import type {
|
import type {
|
||||||
ClientWellKnown, DBEvent, EventID, EventRowID, EventType, RoomID, TimelineRowID, UserID,
|
ClientWellKnown, DBEvent, EventID, EventRowID, EventType, RoomID, TimelineRowID, UserID,
|
||||||
} from "./hitypes.ts"
|
} from "./types/hitypes.ts"
|
||||||
import { ClientState, RPCEvent } from "./hievents.ts"
|
import { ClientState, RPCEvent } from "./types/hievents.ts"
|
||||||
import { RPCClient } from "./rpc.ts"
|
import { RPCClient } from "./rpc.ts"
|
||||||
import { CachedEventDispatcher } from "./eventdispatcher.ts"
|
import { CachedEventDispatcher } from "../util/eventdispatcher.ts"
|
||||||
import { StateStore } from "./statestore.ts"
|
import { StateStore } from "./statestore.ts"
|
||||||
|
|
||||||
export default class Client {
|
export default class Client {
|
|
@ -13,17 +13,9 @@
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import { RPCEvent } from "./hievents.ts"
|
import { RPCEvent } from "./types/hievents.ts"
|
||||||
import { EventDispatcher } from "./eventdispatcher.ts"
|
import { EventDispatcher } from "../util/eventdispatcher.ts"
|
||||||
|
import { CancellablePromise } from "../util/promise.ts"
|
||||||
export class CancellablePromise<T> extends Promise<T> {
|
|
||||||
constructor(
|
|
||||||
executor: (resolve: (value: T) => void, reject: (reason?: Error) => void) => void,
|
|
||||||
readonly cancel: (reason: string) => void,
|
|
||||||
) {
|
|
||||||
super(executor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RPCClient {
|
export interface RPCClient {
|
||||||
connect: EventDispatcher<ConnectionEvent>
|
connect: EventDispatcher<ConnectionEvent>
|
|
@ -22,9 +22,9 @@ import type {
|
||||||
LazyLoadSummary,
|
LazyLoadSummary,
|
||||||
RoomID,
|
RoomID,
|
||||||
TimelineRowTuple,
|
TimelineRowTuple,
|
||||||
} from "./hitypes.ts"
|
} from "./types/hitypes.ts"
|
||||||
import type { EventsDecryptedData, SyncCompleteData, SyncRoom } from "./hievents.ts"
|
import type { EventsDecryptedData, SyncCompleteData, SyncRoom } from "./types/hievents.ts"
|
||||||
import { NonNullCachedEventDispatcher } from "./eventdispatcher.ts"
|
import { NonNullCachedEventDispatcher } from "../util/eventdispatcher.ts"
|
||||||
|
|
||||||
function arraysAreEqual<T>(arr1?: T[], arr2?: T[]): boolean {
|
function arraysAreEqual<T>(arr1?: T[], arr2?: T[]): boolean {
|
||||||
if (!arr1 || !arr2) {
|
if (!arr1 || !arr2) {
|
|
@ -13,9 +13,10 @@
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import { RPCCommand, RPCEvent } from "./hievents.ts"
|
import { RPCCommand, RPCEvent } from "./types/hievents.ts"
|
||||||
import { CachedEventDispatcher, EventDispatcher } from "./eventdispatcher.ts"
|
import { CachedEventDispatcher, EventDispatcher } from "../util/eventdispatcher.ts"
|
||||||
import { CancellablePromise, ConnectionEvent, RPCClient } from "./rpc.ts"
|
import { ConnectionEvent, RPCClient } from "./rpc.ts"
|
||||||
|
import { CancellablePromise } from "../util/promise.ts"
|
||||||
|
|
||||||
export class ErrorResponse extends Error {
|
export class ErrorResponse extends Error {
|
||||||
constructor(public data: unknown) {
|
constructor(public data: unknown) {
|
|
@ -14,8 +14,8 @@
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import type Client from "./client.ts"
|
import type Client from "../api/client.ts"
|
||||||
import type { RoomID } from "./hitypes.ts"
|
import type { RoomID } from "../api/types/hitypes.ts"
|
||||||
import RoomList from "./RoomList.tsx"
|
import RoomList from "./RoomList.tsx"
|
||||||
import RoomView from "./RoomView.tsx"
|
import RoomView from "./RoomView.tsx"
|
||||||
import "./MainScreen.css"
|
import "./MainScreen.css"
|
|
@ -14,10 +14,10 @@
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import React, { useMemo } from "react"
|
import React, { useMemo } from "react"
|
||||||
import Client from "./client.ts"
|
import Client from "../api/client.ts"
|
||||||
import { DBEvent, RoomID } from "./hitypes.ts"
|
import { DBEvent, RoomID } from "../api/types/hitypes.ts"
|
||||||
import { useNonNullEventAsState } from "./eventdispatcher.ts"
|
import { useNonNullEventAsState } from "../util/eventdispatcher.ts"
|
||||||
import { RoomListEntry } from "./statestore.ts"
|
import { RoomListEntry } from "../api/statestore.ts"
|
||||||
import "./RoomList.css"
|
import "./RoomList.css"
|
||||||
|
|
||||||
export interface RoomListProps {
|
export interface RoomListProps {
|
|
@ -13,11 +13,11 @@
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import Client from "./client.ts"
|
import Client from "../api/client.ts"
|
||||||
import { RoomStateStore } from "./statestore.ts"
|
import { RoomStateStore } from "../api/statestore.ts"
|
||||||
import { useNonNullEventAsState } from "./eventdispatcher.ts"
|
import { useNonNullEventAsState } from "../util/eventdispatcher.ts"
|
||||||
import "./RoomView.css"
|
import "./RoomView.css"
|
||||||
import TimelineEvent from "./TimelineEvent.tsx"
|
import TimelineEvent from "./timeline/TimelineEvent.tsx"
|
||||||
|
|
||||||
export interface RoomViewProps {
|
export interface RoomViewProps {
|
||||||
client: Client
|
client: Client
|
|
@ -14,9 +14,9 @@
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import React, { useCallback, useEffect, useState } from "react"
|
import React, { useCallback, useEffect, useState } from "react"
|
||||||
import type Client from "../client.ts"
|
import type Client from "../../api/client.ts"
|
||||||
import "./LoginScreen.css"
|
import "./LoginScreen.css"
|
||||||
import { ClientState } from "../hievents.ts"
|
import { ClientState } from "../../api/types/hievents.ts"
|
||||||
|
|
||||||
export interface LoginScreenProps {
|
export interface LoginScreenProps {
|
||||||
client: Client
|
client: Client
|
|
@ -13,7 +13,7 @@
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import { RoomViewProps } from "./RoomView.tsx"
|
import { RoomViewProps } from "../RoomView.tsx"
|
||||||
import "./TimelineEvent.css"
|
import "./TimelineEvent.css"
|
||||||
|
|
||||||
export interface TimelineEventProps extends RoomViewProps {
|
export interface TimelineEventProps extends RoomViewProps {
|
23
web/src/util/promise.ts
Normal file
23
web/src/util/promise.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// 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 class CancellablePromise<T> extends Promise<T> {
|
||||||
|
constructor(
|
||||||
|
executor: (resolve: (value: T) => void, reject: (reason?: Error) => void) => void,
|
||||||
|
readonly cancel: (reason: string) => void,
|
||||||
|
) {
|
||||||
|
super(executor)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue