index.community/frontend/src/redux/types.ts

162 lines
3.6 KiB
TypeScript
Raw Normal View History

import { RouterState } from "connected-react-router";
2019-08-04 11:39:29 +00:00
import { ISearchFilter } from "../searchFilters";
2018-08-27 15:27:09 +00:00
export enum ActionType {
// Instance details
REQUEST_INSTANCE_DETAILS = "REQUEST_INSTANCE_DETAILS",
RECEIVE_INSTANCE_DETAILS = "RECEIVE_INSTANCE_DETAILS",
INSTANCE_LOAD_ERROR = "INSTANCE_LOAD_ERROR",
// Graph
REQUEST_GRAPH = "REQUEST_GRAPH",
RECEIVE_GRAPH = "RECEIVE_GRAPH",
GRAPH_LOAD_ERROR = "GRAPH_LOAD_ERROR",
2019-08-27 13:50:16 +00:00
// Instance list
REQUEST_INSTANCES = "REQUEST_INSTANCES",
RECEIVE_INSTANCES = "RECEIVE_INSTANCES",
INSTANCE_LIST_LOAD_ERROR = "INSTANCE_LIST_LOAD_ERROR",
// Nav
DESELECT_INSTANCE = "DESELECT_INSTANCE",
// Search
REQUEST_SEARCH_RESULTS = "REQUEST_SEARCH_RESULTS",
RECEIVE_SEARCH_RESULTS = "RECEIVE_SEARCH_RESULTS",
SEARCH_RESULTS_ERROR = "SEARCH_RESULTS_ERROR",
2019-07-26 22:30:11 +00:00
RESET_SEARCH = "RESET_SEARCH",
// Search -- hovering over results
SET_SEARCH_RESULT_HOVER = "SET_SEARCH_RESULT_HOVER"
2018-08-27 15:27:09 +00:00
}
export interface IAction {
type: ActionType;
payload: any;
2018-08-27 15:27:09 +00:00
}
2019-08-29 20:10:37 +00:00
export type SortField = "domain" | "userCount" | "statusCount" | "insularity";
export type SortDirection = "asc" | "desc";
export interface IInstanceSort {
field: SortField;
direction: SortDirection;
}
2019-08-27 13:50:16 +00:00
export interface IPeer {
name: string;
2018-08-27 15:27:09 +00:00
}
export interface ISearchResultInstance {
name: string;
description?: string;
userCount?: number;
2019-07-24 15:51:44 +00:00
type?: string;
}
2019-08-29 16:54:34 +00:00
export interface IFederationRestrictions {
reportRemoval?: string[];
reject?: string[];
mediaRemoval?: string[];
mediaNsfw?: string[];
federatedTimelineRemoval?: string[];
bannerRemoval?: string[];
avatarRemoval?: string[];
accept?: string[];
}
2018-09-01 17:24:05 +00:00
export interface IInstanceDetails {
name: string;
description?: string;
version?: string;
2019-07-18 15:20:09 +00:00
userCount?: number;
insularity?: number;
statusCount?: number;
domainCount?: number;
2019-08-27 13:50:16 +00:00
peers?: IPeer[];
2019-08-29 16:54:34 +00:00
federationRestrictions: IFederationRestrictions;
lastUpdated?: string;
status: string;
2019-07-24 16:25:20 +00:00
type?: string;
2019-07-27 17:58:40 +00:00
statusesPerDay?: number;
statusesPerUserPerDay?: number;
2018-09-01 17:24:05 +00:00
}
interface IGraphNode {
data: {
id: string;
label: string;
size: number;
};
position: {
x: number;
y: number;
};
}
interface IGraphEdge {
data: {
source: string;
target: string;
id: string;
weight: number;
};
}
2019-07-27 17:58:40 +00:00
interface IGraphMetadata {
ranges: { [key: string]: [number, number] };
}
export interface IGraph {
nodes: IGraphNode[];
edges: IGraphEdge[];
}
2019-07-27 17:58:40 +00:00
export interface IGraphResponse {
graph: IGraph;
metadata: IGraphMetadata;
}
export interface ISearchResponse {
results: ISearchResultInstance[];
next: string | null;
}
2019-08-27 13:50:16 +00:00
export interface IInstanceListResponse {
pageNumber: number;
totalPages: number;
totalEntries: number;
pageSize: number;
instances: IInstanceDetails[];
}
// Redux state
// The current instance name is stored in the URL. See state -> router -> location
2018-09-01 17:24:05 +00:00
export interface ICurrentInstanceState {
currentInstanceDetails: IInstanceDetails | null;
isLoadingInstanceDetails: boolean;
error: boolean;
2018-09-01 17:24:05 +00:00
}
2018-08-27 15:27:09 +00:00
export interface IDataState {
2019-07-27 17:58:40 +00:00
graphResponse?: IGraphResponse;
2019-08-27 13:50:16 +00:00
instancesResponse?: IInstanceListResponse;
2019-08-29 20:10:37 +00:00
instanceListSort: IInstanceSort;
isLoadingGraph: boolean;
2019-08-27 13:50:16 +00:00
isLoadingInstanceList: boolean;
graphLoadError: boolean;
instanceListLoadError: boolean;
2018-08-27 15:27:09 +00:00
}
export interface ISearchState {
error: boolean;
isLoadingResults: boolean;
next: string;
query: string;
results: ISearchResultInstance[];
2019-08-04 11:39:29 +00:00
filters: ISearchFilter[];
2019-07-26 22:30:11 +00:00
hoveringOverResult?: string;
}
2018-08-27 15:27:09 +00:00
export interface IAppState {
router: RouterState;
currentInstance: ICurrentInstanceState;
data: IDataState;
search: ISearchState;
2018-09-01 17:24:05 +00:00
}