Skip to content

Commit

Permalink
Simplify typing
Browse files Browse the repository at this point in the history
  • Loading branch information
timendum committed Aug 22, 2024
1 parent 5ee183a commit a67977a
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/fportal/components/addWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { FullFeed } from "../freshrss";
import { type FullFeed } from "../freshrss";

interface AddWidgetProp {
feeds: FullFeed[];
Expand Down
9 changes: 0 additions & 9 deletions app/fportal/components/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ interface WidgetType {
wType?: "simple" | "excerpt";
}

//type HandleCollapse = (name: "toggleCollapse") => void;
//type HandleColor = (name: "color", data: string) => void;
//type HandleConfiguring = (name: "toggleConfiguring") => void;
//type HandleSave = (name: "save") => void;
//type HandleSize = (name: "size", data: string) => void;
//type HandleReset = (name: "reset") => void;

// type HandleCommandType = HandleCollapse | HandleColor | HandleConfiguring | HandleSave | HandleSize | HandleReset;

type HandleCommandType = (name: string, data?: string) => void;

export type { HandleStateChangeType, WidgetType, HandleCommandType };
2 changes: 1 addition & 1 deletion app/fportal/components/login.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { freshRss } from "../freshrss";
import { HandleStateChangeType } from "./interfaces";
import { type HandleStateChangeType } from "./interfaces";

interface LoginFormProps {
handleLogin: HandleStateChangeType;
Expand Down
8 changes: 3 additions & 5 deletions app/fportal/components/main.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react";

import { FullFeed, freshRss } from "../freshrss";
import { type FullFeed, freshRss } from "../freshrss";
import AddWidget from "./addWidget";
import ExpImp from "./expimp";
import Loading from "./loading";
import Topbar from "./topbar";
import { colors, darkPreference } from "./utils";
import Widget from "./widget";

import { HandleStateChangeType, WidgetType } from "./interfaces";
import type { HandleStateChangeType, WidgetType } from "./interfaces";

type setWidgetsType = (widgets: WidgetType[]) => void;

Expand All @@ -25,9 +25,7 @@ function setWidgetsFromStorage(setWidgets: setWidgetsType) {
}
}

type RefreshUnreadType = (feeds: FullFeed[], widgets: WidgetType[]) => void;

const refreshUnread: RefreshUnreadType = (feeds, widgets) => {
const refreshUnread = (feeds: FullFeed[], widgets: WidgetType[]) => {
// Update the faviconc according to the unread count.
const ids = widgets.map((w) => w.id);
let c: string | number = feeds
Expand Down
4 changes: 2 additions & 2 deletions app/fportal/components/mainLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

import ExpImp from "./expimp";
import { HandleStateChangeType } from "./interfaces";
import type { HandleStateChangeType } from "./interfaces";
import LoginForm from "./login";
import Topbar from "./topbar";
import { darkPreference } from "./utils";
Expand All @@ -11,7 +11,7 @@ interface MainLoginProps {
}

export default function MainLogin({ handleLogin }: MainLoginProps) {
const [isExpImp, setExpImp] = React.useState<boolean>(false);
const [isExpImp, setExpImp] = React.useState(false);
const [darkMode, setDarkMode] = React.useState(false);

React.useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion app/fportal/components/topbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React from "react";
import { freshRss } from "../freshrss";
import { HandleStateChangeType } from "./interfaces";
import type { HandleStateChangeType } from "./interfaces";

interface CustomButtonProps {
onClick: React.MouseEventHandler<HTMLElement>;
Expand Down
4 changes: 2 additions & 2 deletions app/fportal/components/widget.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { FeedContent, freshRss, FullFeed } from "../freshrss";
import { WidgetType, HandleCommandType } from "./interfaces";
import type { WidgetType, HandleCommandType } from "./interfaces";

import Loading from "./loading";
import WidgetConfig from "./widgetConfig";
Expand All @@ -24,7 +24,7 @@ export default function Widget({ feed, config, updateConfig, updateFeed, move }:
const [sizeLimit, setSizeLimit] = React.useState(config.sizeLimit || 10);
const [wType, setWType] = React.useState(config.wType || "excerpt");
const [color, setColor] = React.useState(config.color || "gray");
const [pag, setPag] = React.useState<string[]>([""]);
const [pag, setPag] = React.useState([""]);
const [rows, setRows] = React.useState<FeedContent[]>([]);
const { unread } = feed;
React.useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion app/fportal/components/widgetConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

import { WidgetType, HandleCommandType } from "./interfaces";
import type { WidgetType, HandleCommandType } from "./interfaces";

import { colors } from "./utils";

Expand Down
4 changes: 2 additions & 2 deletions app/fportal/components/widgetHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React from "react";

import { FullFeed } from "../freshrss";
import { HandleCommandType } from "./interfaces";
import type { FullFeed } from "../freshrss";
import type { HandleCommandType } from "./interfaces";

interface WidgetHeaderProp {
feed: FullFeed;
Expand Down
4 changes: 2 additions & 2 deletions app/fportal/components/widgetLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

import { FeedContent, freshRss } from "../freshrss";
import { WidgetType } from "./interfaces";
import { type FeedContent, freshRss } from "../freshrss";
import type { WidgetType } from "./interfaces";

interface WidgetLinkProp {
row: FeedContent;
Expand Down
2 changes: 1 addition & 1 deletion app/fportal/components/widgetMove.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { HandleCommandType } from "./interfaces";
import type { HandleCommandType } from "./interfaces";

interface WidgetMoveProp {
handleCommand: HandleCommandType;
Expand Down
2 changes: 1 addition & 1 deletion app/fportal/components/widgetPagination.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

import { FeedContent } from "../freshrss";
import type { FeedContent } from "../freshrss";

interface WidgetPaginationProp {
pag: string[];
Expand Down

0 comments on commit a67977a

Please sign in to comment.