web/all: reorganize files

This commit is contained in:
Tulir Asokan 2024-10-07 01:20:22 +03:00
parent 243ba51002
commit 40b66f3057
22 changed files with 55 additions and 40 deletions

View file

View file

@ -14,14 +14,13 @@
// 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 { useEffect, useMemo, useState } from "react"
import "./App.css"
import Client from "./client.ts"
import WSClient from "./wsclient.ts"
import { ClientState } from "./hievents.ts"
import { ConnectionEvent } from "./rpc.ts"
import { LoginScreen, VerificationScreen } from "./login"
import Client from "./api/client.ts"
import WSClient from "./api/wsclient.ts"
import { ClientState } from "./api/types/hievents.ts"
import { ConnectionEvent } from "./api/rpc.ts"
import { LoginScreen, VerificationScreen } from "./ui/login"
import { ScaleLoader } from "react-spinners"
import MainScreen from "./MainScreen.tsx"
import MainScreen from "./ui/MainScreen.tsx"
function App() {
const [connState, setConnState] = useState<ConnectionEvent>()

View file

@ -15,10 +15,10 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import type {
ClientWellKnown, DBEvent, EventID, EventRowID, EventType, RoomID, TimelineRowID, UserID,
} from "./hitypes.ts"
import { ClientState, RPCEvent } from "./hievents.ts"
} from "./types/hitypes.ts"
import { ClientState, RPCEvent } from "./types/hievents.ts"
import { RPCClient } from "./rpc.ts"
import { CachedEventDispatcher } from "./eventdispatcher.ts"
import { CachedEventDispatcher } from "../util/eventdispatcher.ts"
import { StateStore } from "./statestore.ts"
export default class Client {

View file

@ -13,17 +13,9 @@
//
// 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 { RPCEvent } from "./hievents.ts"
import { EventDispatcher } from "./eventdispatcher.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)
}
}
import { RPCEvent } from "./types/hievents.ts"
import { EventDispatcher } from "../util/eventdispatcher.ts"
import { CancellablePromise } from "../util/promise.ts"
export interface RPCClient {
connect: EventDispatcher<ConnectionEvent>

View file

@ -22,9 +22,9 @@ import type {
LazyLoadSummary,
RoomID,
TimelineRowTuple,
} from "./hitypes.ts"
import type { EventsDecryptedData, SyncCompleteData, SyncRoom } from "./hievents.ts"
import { NonNullCachedEventDispatcher } from "./eventdispatcher.ts"
} from "./types/hitypes.ts"
import type { EventsDecryptedData, SyncCompleteData, SyncRoom } from "./types/hievents.ts"
import { NonNullCachedEventDispatcher } from "../util/eventdispatcher.ts"
function arraysAreEqual<T>(arr1?: T[], arr2?: T[]): boolean {
if (!arr1 || !arr2) {

View file

@ -13,9 +13,10 @@
//
// 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 { RPCCommand, RPCEvent } from "./hievents.ts"
import { CachedEventDispatcher, EventDispatcher } from "./eventdispatcher.ts"
import { CancellablePromise, ConnectionEvent, RPCClient } from "./rpc.ts"
import { RPCCommand, RPCEvent } from "./types/hievents.ts"
import { CachedEventDispatcher, EventDispatcher } from "../util/eventdispatcher.ts"
import { ConnectionEvent, RPCClient } from "./rpc.ts"
import { CancellablePromise } from "../util/promise.ts"
export class ErrorResponse extends Error {
constructor(public data: unknown) {

View file

@ -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 { useState } from "react"
import type Client from "./client.ts"
import type { RoomID } from "./hitypes.ts"
import type Client from "../api/client.ts"
import type { RoomID } from "../api/types/hitypes.ts"
import RoomList from "./RoomList.tsx"
import RoomView from "./RoomView.tsx"
import "./MainScreen.css"

View file

@ -14,10 +14,10 @@
// 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, { useMemo } from "react"
import Client from "./client.ts"
import { DBEvent, RoomID } from "./hitypes.ts"
import { useNonNullEventAsState } from "./eventdispatcher.ts"
import { RoomListEntry } from "./statestore.ts"
import Client from "../api/client.ts"
import { DBEvent, RoomID } from "../api/types/hitypes.ts"
import { useNonNullEventAsState } from "../util/eventdispatcher.ts"
import { RoomListEntry } from "../api/statestore.ts"
import "./RoomList.css"
export interface RoomListProps {

View file

@ -13,11 +13,11 @@
//
// 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 Client from "./client.ts"
import { RoomStateStore } from "./statestore.ts"
import { useNonNullEventAsState } from "./eventdispatcher.ts"
import Client from "../api/client.ts"
import { RoomStateStore } from "../api/statestore.ts"
import { useNonNullEventAsState } from "../util/eventdispatcher.ts"
import "./RoomView.css"
import TimelineEvent from "./TimelineEvent.tsx"
import TimelineEvent from "./timeline/TimelineEvent.tsx"
export interface RoomViewProps {
client: Client

View file

@ -14,9 +14,9 @@
// 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, useEffect, useState } from "react"
import type Client from "../client.ts"
import type Client from "../../api/client.ts"
import "./LoginScreen.css"
import { ClientState } from "../hievents.ts"
import { ClientState } from "../../api/types/hievents.ts"
export interface LoginScreenProps {
client: Client

View file

@ -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 { RoomViewProps } from "./RoomView.tsx"
import { RoomViewProps } from "../RoomView.tsx"
import "./TimelineEvent.css"
export interface TimelineEventProps extends RoomViewProps {

23
web/src/util/promise.ts Normal file
View 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)
}
}