From 1a3bbe4ec93f82cc6e4d7071c1363e488ba3075a Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Wed, 5 May 2021 21:20:34 -0700 Subject: [PATCH 1/3] interface: cleaning up typescript errors --- pkg/interface/src/logic/api/graph.ts | 5 +- pkg/interface/src/logic/lib/hark.ts | 3 +- pkg/interface/src/logic/lib/permalinks.ts | 5 +- pkg/interface/src/logic/lib/publish.ts | 4 +- pkg/interface/src/logic/lib/useModal.tsx | 10 +-- .../src/logic/lib/{util.ts => util.tsx} | 9 ++- pkg/interface/src/logic/lib/withState.tsx | 12 +-- .../src/logic/reducers/graph-update.ts | 7 +- .../src/logic/reducers/hark-update.ts | 12 ++- pkg/interface/src/logic/state/base.ts | 8 +- .../views/apps/chat/components/ChatEditor.tsx | 20 +++-- .../views/apps/chat/components/ChatInput.tsx | 2 +- .../apps/chat/components/ChatMessage.tsx | 76 +++++++++---------- .../views/apps/chat/components/ChatPane.tsx | 6 +- .../views/apps/chat/components/ChatWindow.tsx | 16 ++-- .../apps/chat/components/UnreadNotice.tsx | 10 +-- pkg/interface/src/views/apps/graph/App.tsx | 5 +- pkg/interface/src/views/apps/launch/App.tsx | 32 ++++---- .../views/apps/launch/components/Groups.tsx | 8 +- .../views/apps/launch/components/tiles.tsx | 6 +- .../apps/launch/components/tiles/basic.tsx | 2 +- .../apps/launch/components/tiles/clock.tsx | 37 ++++++++- .../apps/launch/components/tiles/custom.tsx | 2 +- .../apps/launch/components/tiles/tile.tsx | 17 ++++- .../apps/launch/components/tiles/weather.tsx | 53 +++++++------ .../src/views/apps/links/LinkWindow.tsx | 13 +++- .../views/apps/links/components/LinkItem.tsx | 25 +++--- .../src/views/apps/notifications/graph.tsx | 33 +++----- .../src/views/apps/notifications/group.tsx | 3 +- .../src/views/apps/notifications/header.tsx | 12 +-- .../src/views/apps/notifications/inbox.tsx | 16 ++-- .../src/views/apps/notifications/joining.tsx | 8 +- .../src/views/apps/notifications/metadata.tsx | 12 +-- .../views/apps/notifications/notification.tsx | 10 +-- .../apps/notifications/notifications.tsx | 12 +-- .../views/apps/permalinks/TranscludedNode.tsx | 42 +++++----- .../src/views/apps/permalinks/app.tsx | 4 +- .../src/views/apps/permalinks/embed.tsx | 22 +++--- .../src/views/apps/permalinks/graphIndex.tsx | 4 +- .../apps/profile/components/EditProfile.tsx | 22 +++--- .../views/apps/profile/components/Profile.tsx | 24 +++--- .../apps/profile/components/ViewProfile.tsx | 6 +- .../src/views/apps/profile/profile.tsx | 2 +- .../apps/publish/components/EditPost.tsx | 5 +- .../publish/components/MarkdownEditor.tsx | 9 +-- .../apps/publish/components/MarkdownField.tsx | 2 +- .../views/apps/publish/components/Note.tsx | 13 ++-- .../publish/components/NoteNavigation.tsx | 6 +- .../apps/publish/components/NotePreview.tsx | 12 +-- .../apps/publish/components/NoteRoutes.tsx | 3 +- .../apps/publish/components/Notebook.tsx | 4 +- .../views/apps/publish/components/Writers.tsx | 10 +-- .../settings/components/lib/BackButton.tsx | 2 +- .../components/lib/BackgroundPicker.tsx | 14 ++-- .../settings/components/lib/BucketList.tsx | 16 ++-- .../apps/settings/components/lib/CalmPref.tsx | 8 +- .../apps/settings/components/lib/Debug.tsx | 8 +- .../settings/components/lib/DisplayForm.tsx | 10 +-- .../components/lib/GroupChannelPicker.tsx | 16 ++-- .../settings/components/lib/LeapSettings.tsx | 16 ++-- .../components/lib/NotificationPref.tsx | 14 ++-- .../apps/settings/components/lib/S3Form.tsx | 18 ++--- .../apps/settings/components/lib/Security.tsx | 16 ++-- .../apps/settings/components/settings.tsx | 14 ++-- .../src/views/apps/settings/settings.tsx | 6 +- pkg/interface/src/views/apps/term/api.tsx | 5 +- pkg/interface/src/views/apps/term/app.tsx | 15 ++-- .../views/apps/term/components/history.tsx | 4 +- .../src/views/apps/term/components/input.tsx | 12 +-- .../src/views/apps/term/components/line.tsx | 2 +- pkg/interface/src/views/apps/term/store.tsx | 4 + .../src/views/apps/term/subscription.tsx | 8 +- pkg/interface/src/views/components/Author.tsx | 5 +- .../src/views/components/ChipInput.tsx | 40 +++++----- .../src/views/components/ColorInput.tsx | 14 ++-- .../src/views/components/CommentItem.tsx | 17 +++-- .../src/views/components/Comments.tsx | 4 +- .../src/views/components/Dropdown.tsx | 6 +- .../src/views/components/DropdownSearch.tsx | 18 ++--- pkg/interface/src/views/components/Error.tsx | 2 +- .../src/views/components/FormGroup.tsx | 10 +-- .../src/views/components/FormSubmit.tsx | 4 +- .../src/views/components/GroupLink.tsx | 11 +-- .../src/views/components/GroupSearch.tsx | 22 +++--- .../src/views/components/IconRadio.tsx | 14 ++-- .../src/views/components/ImageInput.tsx | 4 +- .../src/views/components/Invite/Group.tsx | 21 +++-- .../components/Invite/InviteSkeleton.tsx | 6 +- .../views/components/Invite/JoinSkeleton.tsx | 2 +- .../src/views/components/Loading.tsx | 2 +- .../src/views/components/MentionText.tsx | 2 +- .../src/views/components/OverlaySigil.tsx | 19 +++-- .../src/views/components/ProfileOverlay.tsx | 53 +++++++------ .../src/views/components/ReconnectButton.tsx | 4 +- .../src/views/components/RemoteContent.tsx | 13 ++-- .../src/views/components/RichText.tsx | 21 ++++- .../src/views/components/ShipSearch.tsx | 20 ++--- .../src/views/components/ShuffleFields.tsx | 12 +-- .../src/views/components/Spinner.tsx | 4 +- .../views/components/StatelessAsyncToggle.tsx | 2 +- .../src/views/components/StatusBar.tsx | 20 ++--- .../src/views/components/SubmitDragger.tsx | 10 +-- .../src/views/components/UnjoinedResource.tsx | 12 +-- .../src/views/components/VirtualScroller.tsx | 12 +-- .../src/views/components/leap/Omnibox.tsx | 16 ++-- .../views/components/leap/OmniboxInput.tsx | 6 +- .../views/components/leap/OmniboxResult.tsx | 24 +++--- .../ChannelPermissions.tsx | 22 +++--- .../ChannelPopoverRoutes/Details.tsx | 12 +-- .../ChannelPopoverRoutes/Notifications.tsx | 6 +- .../ChannelPopoverRoutes/Sidebar.tsx | 12 +-- .../components/ChannelPopoverRoutes/index.tsx | 38 +++++----- .../components/ChannelWritePerms.tsx | 6 +- .../landscape/components/DeleteGroup.tsx | 12 +-- .../components/Graph/GraphContent.tsx | 76 ++++++++----------- .../components/Graph/content/code.js | 18 ++--- .../components/Graph/content/text.js | 24 +++--- .../components/GroupSettings/Admin.tsx | 12 +-- .../components/GroupSettings/Channels.tsx | 16 ++-- .../components/GroupSettings/GroupFeed.tsx | 8 +- .../GroupSettings/GroupSettings.tsx | 6 +- .../components/GroupSettings/Personal.tsx | 12 +-- .../landscape/components/GroupSummary.tsx | 14 ++-- .../landscape/components/GroupSwitcher.tsx | 22 +++--- .../landscape/components/GroupifyForm.tsx | 2 +- .../components/Home/AddFeedBanner.tsx | 6 +- .../components/Home/EmptyGroupHome.tsx | 2 +- .../components/Home/EnableGroupFeed.tsx | 10 +-- .../components/Home/GroupFeedHeader.tsx | 16 ++-- .../landscape/components/Home/GroupHome.tsx | 8 +- .../components/Home/Post/GroupFeedPerms.tsx | 6 +- .../components/Home/Post/PostFeed.tsx | 24 +++++- .../components/Home/Post/PostInput.tsx | 16 ++-- .../Home/Post/PostItem/PostContent.tsx | 8 +- .../Home/Post/PostItem/PostHeader.tsx | 6 +- .../Home/Post/PostItem/PostItem.tsx | 65 ++++++++++------ .../components/Home/Post/PostReplies.tsx | 15 ++-- .../components/Home/Post/PostTimeline.tsx | 48 +++++++----- .../landscape/components/InvitePopover.tsx | 8 +- .../views/landscape/components/JoinGroup.tsx | 32 ++++---- .../landscape/components/MessageInvite.tsx | 17 +++-- .../landscape/components/MetadataIcon.tsx | 2 +- .../views/landscape/components/NewChannel.tsx | 27 +++---- .../views/landscape/components/NewGroup.tsx | 11 +-- .../landscape/components/Participants.tsx | 34 ++++----- .../landscape/components/PopoverRoutes.tsx | 8 +- .../landscape/components/ResourceSkeleton.tsx | 24 +++--- .../landscape/components/Sidebar/Sidebar.tsx | 4 +- .../components/Sidebar/SidebarItem.tsx | 4 +- .../components/Sidebar/SidebarListHeader.tsx | 14 ++-- .../landscape/components/SidebarItem.tsx | 6 +- .../landscape/components/TutorialModal.tsx | 34 ++++----- pkg/npm/api/hark/types.ts | 4 +- pkg/npm/api/metadata/types.ts | 6 +- 154 files changed, 1151 insertions(+), 993 deletions(-) rename pkg/interface/src/logic/lib/{util.ts => util.tsx} (97%) diff --git a/pkg/interface/src/logic/api/graph.ts b/pkg/interface/src/logic/api/graph.ts index 95ca69ac2f..12fffce3a7 100644 --- a/pkg/interface/src/logic/api/graph.ts +++ b/pkg/interface/src/logic/api/graph.ts @@ -1,4 +1,5 @@ import { Content, Enc, GraphNode, GroupPolicy, Path, Patp, Post, Resource } from '@urbit/api'; +import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap'; import _ from 'lodash'; import { decToUd, deSig, resourceAsPath, unixToDa } from '~/logic/lib/util'; import { makeResource, resourceFromPath } from '../lib/group'; @@ -9,7 +10,7 @@ export const createBlankNodeWithChildPost = ( parentIndex = '', childIndex = '', contents: Content[] -) => { +): GraphNode => { const date = unixToDa(Date.now()).toString(); const nodeIndex = parentIndex + '/' + date; @@ -35,7 +36,7 @@ export const createBlankNodeWithChildPost = ( hash: null, signatures: [] }, - children: childGraph + children: childGraph as BigIntOrderedMap }; }; diff --git a/pkg/interface/src/logic/lib/hark.ts b/pkg/interface/src/logic/lib/hark.ts index f410e88d31..a5fe5883ea 100644 --- a/pkg/interface/src/logic/lib/hark.ts +++ b/pkg/interface/src/logic/lib/hark.ts @@ -1,5 +1,6 @@ import { IndexedNotification, NotificationGraphConfig, Unreads } from '@urbit/api'; import bigInt, { BigInteger } from 'big-integer'; +import _ from 'lodash'; import f from 'lodash/fp'; export function getLastSeen( @@ -31,7 +32,7 @@ export function getNotificationCount( ): number { const unread = unreads.graph?.[path] || {}; return Object.keys(unread) - .map(index => unread[index]?.notifications?.length || 0) + .map(index => _.get(unread[index], 'notifications.length', 0)) .reduce(f.add, 0); } diff --git a/pkg/interface/src/logic/lib/permalinks.ts b/pkg/interface/src/logic/lib/permalinks.ts index c6e0905495..d225dc317b 100644 --- a/pkg/interface/src/logic/lib/permalinks.ts +++ b/pkg/interface/src/logic/lib/permalinks.ts @@ -20,12 +20,13 @@ function getPermalinkForAssociatedGroup(group: string) { type Permalink = GraphPermalink | GroupPermalink; -interface GroupPermalink { +export interface GroupPermalink { type: 'group'; group: string; link: string; } -interface GraphPermalink { + +export interface GraphPermalink { type: 'graph'; link: string; graph: string; diff --git a/pkg/interface/src/logic/lib/publish.ts b/pkg/interface/src/logic/lib/publish.ts index 487fcdfd3f..c6478bbd7a 100644 --- a/pkg/interface/src/logic/lib/publish.ts +++ b/pkg/interface/src/logic/lib/publish.ts @@ -1,4 +1,4 @@ -import { GraphNode, Post, TextContent } from '@urbit/api'; +import { Content, GraphNode, Post } from '@urbit/api'; import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap'; import bigInt, { BigInteger } from 'big-integer'; import { buntPost } from '~/logic/lib/post'; @@ -118,7 +118,7 @@ export function getComments(node: GraphNode): GraphNode { return comments; } -export function getSnippet(body: any) { +export function getSnippet(body: string | Content[]) { const firstContent = Object.values(body[0])[0]; const newlineIdx = firstContent.indexOf('\n', 2); const end = newlineIdx > -1 ? newlineIdx : firstContent.length; diff --git a/pkg/interface/src/logic/lib/useModal.tsx b/pkg/interface/src/logic/lib/useModal.tsx index 95adb05706..9edbf011ab 100644 --- a/pkg/interface/src/logic/lib/useModal.tsx +++ b/pkg/interface/src/logic/lib/useModal.tsx @@ -1,9 +1,9 @@ import { Box } from '@tlon/indigo-react'; import React, { - ReactNode, - useCallback, - useMemo, - useRef, useState + ReactNode, + useCallback, + useMemo, + useRef, useState } from 'react'; import { PropFunc } from '~/types'; import { ModalOverlay } from '~/views/components/ModalOverlay'; @@ -57,7 +57,7 @@ export function useModal(props: UseModalProps & PropFunc): UseModalR display="flex" alignItems="stretch" flexDirection="column" - spacing="2" + spacing={2} dismiss={dismiss} {...rest} > diff --git a/pkg/interface/src/logic/lib/util.ts b/pkg/interface/src/logic/lib/util.tsx similarity index 97% rename from pkg/interface/src/logic/lib/util.ts rename to pkg/interface/src/logic/lib/util.tsx index 2b20c7047e..9d5911c4b4 100644 --- a/pkg/interface/src/logic/lib/util.ts +++ b/pkg/interface/src/logic/lib/util.tsx @@ -5,7 +5,7 @@ import bigInt, { BigInteger } from 'big-integer'; import { enableMapSet } from 'immer'; import _ from 'lodash'; import f from 'lodash/fp'; -import { useCallback, useEffect, useMemo, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { IconRef } from '~/types'; import useSettingsState from '../state/settings'; @@ -423,6 +423,13 @@ export const useHovering = (): useHoveringInterface => { return useMemo(() => ({ hovering, bind }), [hovering, bind]); }; +export function withHovering(Component: React.ComponentType) { + const { hovering, bind } = useHovering(); + return (props: T) => ( + + ) +} + const DM_REGEX = /ship\/~([a-z]|-)*\/dm--/; export function getItemTitle(association: Association): string { if (DM_REGEX.test(association.resource)) { diff --git a/pkg/interface/src/logic/lib/withState.tsx b/pkg/interface/src/logic/lib/withState.tsx index 1ccd661468..80fdce4c15 100644 --- a/pkg/interface/src/logic/lib/withState.tsx +++ b/pkg/interface/src/logic/lib/withState.tsx @@ -19,12 +19,14 @@ const withStateo = < }); }; -const withState = < - StateType extends BaseState, - stateKey extends keyof StateType - >( +interface StatePicker extends Array { + 0: UseStore; + 1?: string[]; +} + +const withState = ( Component: any, - stores: ([UseStore, stateKey[]])[] + stores: StatePicker[] ) => { return React.forwardRef((props, ref) => { const stateProps: unknown = {}; diff --git a/pkg/interface/src/logic/reducers/graph-update.ts b/pkg/interface/src/logic/reducers/graph-update.ts index 1bb7632787..b049119131 100644 --- a/pkg/interface/src/logic/reducers/graph-update.ts +++ b/pkg/interface/src/logic/reducers/graph-update.ts @@ -1,3 +1,4 @@ +import { GraphNode } from '@urbit/api'; import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap'; import bigInt, { BigInteger } from 'big-integer'; import produce from 'immer'; @@ -52,14 +53,14 @@ const keys = (json, state: GraphState): GraphState => { const processNode = (node) => { // is empty if (!node.children) { - return produce(node, (draft) => { + return produce(node, (draft: GraphNode) => { draft.children = new BigIntOrderedMap(); }); } // is graph - return produce(node, (draft) => { - draft.children = new BigIntOrderedMap() + return produce(node, (draft: GraphNode) => { + draft.children = new BigIntOrderedMap() .gas(_.map(draft.children, (item, idx) => [bigInt(idx), processNode(item)] as [BigInteger, any] )); diff --git a/pkg/interface/src/logic/reducers/hark-update.ts b/pkg/interface/src/logic/reducers/hark-update.ts index f40b9f2854..50978b4e3a 100644 --- a/pkg/interface/src/logic/reducers/hark-update.ts +++ b/pkg/interface/src/logic/reducers/hark-update.ts @@ -64,11 +64,19 @@ function calculateCount(json: any, state: HarkState) { let count = 0; _.forEach(state.unreads.graph, (graphs) => { _.forEach(graphs, (graph) => { - count += (graph?.notifications || []).length; + if (typeof graph?.notifications === 'object') { + count += graph?.notifications.length; + } else { + count += 0; + } }); }); _.forEach(state.unreads.group, (group) => { - count += (group?.notifications || []).length; + if (typeof group?.notifications === 'object') { + count += group?.notifications.length; + } else { + count += 0; + } }); state.notificationsCount = count; return state; diff --git a/pkg/interface/src/logic/state/base.ts b/pkg/interface/src/logic/state/base.ts index 4286d2dcd1..c987df77a7 100644 --- a/pkg/interface/src/logic/state/base.ts +++ b/pkg/interface/src/logic/state/base.ts @@ -44,13 +44,13 @@ export interface BaseState extends State { set: (fn: (state: StateType) => void) => void; } -export const createState = ( +export const createState = >( name: string, - properties: T, + properties: { [K in keyof Omit]: T[K] }, blacklist: string[] = [] -): UseStore> => create(persist((set, get) => ({ +): UseStore => create(persist((set, get) => ({ set: fn => stateSetter(fn, set), - ...properties + ...properties as any }), { blacklist, name: stateStorageKey(name), diff --git a/pkg/interface/src/views/apps/chat/components/ChatEditor.tsx b/pkg/interface/src/views/apps/chat/components/ChatEditor.tsx index 3a805fc439..2f7a0b99d6 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatEditor.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatEditor.tsx @@ -108,8 +108,18 @@ interface ChatEditorState { message: string; } +interface CodeMirrorShim { + setValue: (string) => void; + setOption: (option: string, property: any) => void; + focus: () => void; + execCommand: (string) => void; + getValue: () => string; + getInputField: () => HTMLInputElement; + element: HTMLElement; +} + export default class ChatEditor extends Component { - editor: ProxyHandler | null; + editor: CodeMirrorShim; constructor(props: ChatEditorProps) { super(props); @@ -222,7 +232,7 @@ export default class ChatEditor extends Component { if (this.editor) { @@ -245,7 +255,7 @@ export default class ChatEditor extends Component - this.messageChange(null, null, event.target.value) + this.messageChange(null, null, (event.target as any).value) } ref={(input) => { if (!input) diff --git a/pkg/interface/src/views/apps/chat/components/ChatInput.tsx b/pkg/interface/src/views/apps/chat/components/ChatInput.tsx index 2f443fec2b..5d0524ed43 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatInput.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatInput.tsx @@ -29,7 +29,7 @@ interface ChatInputState { currentInput: string; } -class ChatInput extends Component { +export class ChatInput extends Component { private chatEditor: React.RefObject; constructor(props) { diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index e41212abfd..74e53d2470 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -1,9 +1,10 @@ /* eslint-disable max-lines-per-function */ import { BaseImage, Box, Col, Icon, Row, Rule, Text } from '@tlon/indigo-react'; -import { Contact, Post } from '@urbit/api'; +import { Contact, MentionContent, Post } from '@urbit/api'; import bigInt from 'big-integer'; import moment from 'moment'; import React, { + Ref, useEffect, useMemo, useState } from 'react'; @@ -22,13 +23,13 @@ import useLocalState from '~/logic/state/local'; import useSettingsState, { selectCalmState } from '~/logic/state/settings'; import { Dropdown } from '~/views/components/Dropdown'; import ProfileOverlay from '~/views/components/ProfileOverlay'; -import { GraphContent} from '~/views/landscape/components/Graph/GraphContent'; +import { GraphContent } from '~/views/landscape/components/Graph/GraphContent'; export const DATESTAMP_FORMAT = '[~]YYYY.M.D'; interface DayBreakProps { - when: string; + when: string | number; shimTop?: boolean; } @@ -57,7 +58,7 @@ export const DayBreak = ({ when, shimTop = false }: DayBreakProps) => ( ); export const UnreadMarker = React.forwardRef( - ({ dismissUnread }: any, ref) => { + ({ dismissUnread }: any, ref: Ref) => { const [visible, setVisible] = useState(false); const idling = useIdlingState(); @@ -115,7 +116,7 @@ const MessageActionItem = (props) => { ); }; -const MessageActions = ({ api, onReply, onDelete, association, msg, isAdmin, permalink }) => { +const MessageActions = ({ onReply, onDelete, msg, isAdmin, permalink }) => { const isOwn = () => msg.author === window.ship; const { doCopy, copyDisplay } = useCopy(permalink, 'Copy Message Link'); @@ -189,7 +190,7 @@ const MessageWrapper = (props) => { const showHover = (props.transcluded === 0) && hovering && !props.hideHover; return ( void; + dismissUnread?: () => void; api: GlobalApi; highlighted?: boolean; renderSigil?: boolean; @@ -222,27 +223,24 @@ interface ChatMessageProps { innerRef: (el: HTMLDivElement | null) => void; onReply?: (msg: Post) => void; showOurContact: boolean; + onDelete?: () => void; } function ChatMessage(props: ChatMessageProps) { let { highlighted } = props; const { msg, - previousMsg, nextMsg, - isLastRead, - group, - association, + isLastRead = false, className = '', - isPending, + isPending = false, style, isLastMessage, api, showOurContact, - fontSize, hideHover, - dismissUnread, - permalink + dismissUnread = () => null, + permalink = '' } = props; if (typeof msg === 'string' || !msg) { @@ -259,7 +257,7 @@ function ChatMessage(props: ChatMessageProps) { msg.number === 1 ); - const ourMention = msg?.contents?.some((e) => { + const ourMention = msg?.contents?.some((e: MentionContent) => { return e?.mention && e?.mention === window.ship; }); @@ -293,12 +291,10 @@ function ChatMessage(props: ChatMessageProps) { const messageProps = { msg, timestamp, - association, isPending, showOurContact, api, highlighted, - fontSize, hideHover, transcluded, onReply, @@ -423,7 +419,7 @@ export const MessageAuthor = ({ ); return ( - + ( diff --git a/pkg/interface/src/views/apps/chat/components/ChatPane.tsx b/pkg/interface/src/views/apps/chat/components/ChatPane.tsx index ed283c3340..dd6ebf46fb 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatPane.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatPane.tsx @@ -11,7 +11,7 @@ import useGraphState from '~/logic/state/graph'; import ShareProfile from '~/views/apps/chat/components/ShareProfile'; import { Loading } from '~/views/components/Loading'; import SubmitDragger from '~/views/components/SubmitDragger'; -import ChatInput from './ChatInput'; +import ChatInput, { ChatInput as NakedChatInput } from './ChatInput'; import ChatWindow from './ChatWindow'; interface ChatPaneProps { @@ -82,14 +82,14 @@ export function ChatPane(props: ChatPaneProps): ReactElement { } = props; const graphTimesentMap = useGraphState(state => state.graphTimesentMap); const ourContact = useOurContact(); - const chatInput = useRef(); + const chatInput = useRef(); const onFileDrag = useCallback( (files: FileList | File[]) => { if (!chatInput.current) { return; } - chatInput.current?.uploadFiles(files); + (chatInput.current as NakedChatInput)?.uploadFiles(files); }, [chatInput.current] ); diff --git a/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx b/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx index b7ca5a39c5..b721601665 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx @@ -16,7 +16,7 @@ type ChatWindowProps = { unreadCount: number; graph: Graph; graphSize: number; - station: unknown; + station?: unknown; fetchMessages: (newer: boolean) => Promise; api: GlobalApi; scrollTo?: BigInteger; @@ -36,6 +36,11 @@ interface ChatWindowState { unreadIndex: BigInteger; } +interface RendererProps { + index: bigInt.BigInteger; + scrollWindow: any; +} + const virtScrollerStyle = { height: '100%' }; class ChatWindow extends Component< @@ -99,11 +104,12 @@ class ChatWindow extends Component< }); } - dismissedInitialUnread(): void { + dismissedInitialUnread(): boolean { const { unreadCount, graph } = this.props; - return this.state.unreadIndex.eq(bigInt.zero) ? unreadCount > graph.size : - this.state.unreadIndex.neq(graph.keys()?.[unreadCount]?.[0] ?? bigInt.zero); + return this.state.unreadIndex.eq(bigInt.zero) + ? unreadCount > graph.size + : this.state.unreadIndex.neq(graph.keys()?.[unreadCount]?.[0] ?? bigInt.zero); } handleWindowBlur(): void { @@ -173,7 +179,7 @@ class ChatWindow extends Component< } } - renderer = React.forwardRef(({ index, scrollWindow }, ref) => { + renderer = React.forwardRef(({ index, scrollWindow }: RendererProps, ref) => { const { api, showOurContact, diff --git a/pkg/interface/src/views/apps/chat/components/UnreadNotice.tsx b/pkg/interface/src/views/apps/chat/components/UnreadNotice.tsx index ac5a34f89c..a81acf014b 100644 --- a/pkg/interface/src/views/apps/chat/components/UnreadNotice.tsx +++ b/pkg/interface/src/views/apps/chat/components/UnreadNotice.tsx @@ -22,16 +22,16 @@ const UnreadNotice = (props): ReactElement | null => { className='unread-notice' >
- + { if(!graphKeys.has(resource)) { autoJoin(); - } else if(Boolean(association) && 'graph' in association.config) { - history.push(`/~landscape/home/resource/${association.metadata.config.graph}${path}`); + } else if(Boolean(association) && 'graph' in association.metadata.config) { + history.push(`/~landscape/home/resource/${(association.metadata.config as GraphConfig).graph}${path}`); } return (
diff --git a/pkg/interface/src/views/apps/launch/App.tsx b/pkg/interface/src/views/apps/launch/App.tsx index 791a42402b..0d7b783fe6 100644 --- a/pkg/interface/src/views/apps/launch/App.tsx +++ b/pkg/interface/src/views/apps/launch/App.tsx @@ -6,13 +6,13 @@ import { Helmet } from 'react-helmet'; import styled from 'styled-components'; import GlobalApi from '~/logic/api/global'; import { - hasTutorialGroup, + hasTutorialGroup, - TUTORIAL_BOOK, - TUTORIAL_CHAT, TUTORIAL_GROUP, - TUTORIAL_HOST, + TUTORIAL_BOOK, + TUTORIAL_CHAT, TUTORIAL_GROUP, + TUTORIAL_HOST, - TUTORIAL_LINKS + TUTORIAL_LINKS } from '~/logic/lib/tutorialModal'; import { useModal } from '~/logic/lib/useModal'; import { useQuery } from '~/logic/lib/useQuery'; @@ -67,8 +67,8 @@ export const LaunchApp = (props: LaunchAppProps): ReactElement | null => { const hashBox = ( { dismiss(); }; return exitingTut ? ( - + - + You can always restart the tutorial by typing “tutorial” in Leap - + ) : ( - + - Welcome - + Welcome + You have been invited to use Landscape, an interface to chat and interact with communities
Would you like a tour of Landscape?
- + } @@ -125,7 +125,7 @@ export function NotificationWrapper(props: { {children} - + ); }); @@ -67,21 +67,21 @@ export default function NotificationsScreen(props: any): ReactElement { - + Notifications - + diff --git a/pkg/interface/src/views/apps/permalinks/TranscludedNode.tsx b/pkg/interface/src/views/apps/permalinks/TranscludedNode.tsx index c5047e60ad..1dba297736 100644 --- a/pkg/interface/src/views/apps/permalinks/TranscludedNode.tsx +++ b/pkg/interface/src/views/apps/permalinks/TranscludedNode.tsx @@ -1,5 +1,5 @@ import { Anchor, Box, Col, Icon, Row, Text } from '@tlon/indigo-react'; -import { Association, GraphNode, Group, Post } from '@urbit/api'; +import { Association, GraphConfig, GraphNode, Group, Post, ReferenceContent, TextContent, UrlContent } from '@urbit/api'; import bigInt from 'big-integer'; import React from 'react'; import GlobalApi from '~/logic/api/global'; @@ -28,20 +28,21 @@ function TranscludedLinkNode(props: { switch (idx.length) { case 1: - const [{ text }, link] = node.post.contents; + const [{ text }, link] = node.post.contents as [TextContent, UrlContent | ReferenceContent]; if('reference' in link) { const permalink = referenceToPermalink(link).link; return ; } return ( - + - + {text} ); + case 2: return ( - + + - - {post.post.contents[0]?.text} + + {(post.post.contents[0] as TextContent)?.text} - + @@ -160,13 +161,13 @@ export function TranscludedPost(props: { return ( - + ); diff --git a/pkg/interface/src/views/apps/permalinks/app.tsx b/pkg/interface/src/views/apps/permalinks/app.tsx index cfbd8b82ca..3e29a7e5c6 100644 --- a/pkg/interface/src/views/apps/permalinks/app.tsx +++ b/pkg/interface/src/views/apps/permalinks/app.tsx @@ -1,4 +1,4 @@ -import { Association } from '@urbit/api'; +import { Association, GraphConfig } from '@urbit/api'; import React, { useCallback } from 'react'; import { Redirect, Route, Switch @@ -82,7 +82,7 @@ function GroupRoutes(props: { group: string; url: string }) { return ; } diff --git a/pkg/interface/src/views/apps/permalinks/embed.tsx b/pkg/interface/src/views/apps/permalinks/embed.tsx index ac21851c46..cb4203f935 100644 --- a/pkg/interface/src/views/apps/permalinks/embed.tsx +++ b/pkg/interface/src/views/apps/permalinks/embed.tsx @@ -3,14 +3,14 @@ import { Col, Icon, Row, Text } from '@tlon/indigo-react'; -import { Association, GraphNode, resourceFromPath } from '@urbit/api'; +import { Association, GraphConfig, GraphNode, resourceFromPath } from '@urbit/api'; import React, { useCallback, useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import GlobalApi from '~/logic/api/global'; import { getPermalinkForGraph, GraphPermalink as IGraphPermalink, parsePermalink } from '~/logic/lib/permalinks'; -import { getModuleIcon } from '~/logic/lib/util'; +import { getModuleIcon, GraphModule } from '~/logic/lib/util'; import { useVirtualResizeProp } from '~/logic/lib/virtualContext'; import useGraphState from '~/logic/state/graph'; import useMetadataState from '~/logic/state/metadata'; @@ -23,9 +23,9 @@ function GroupPermalink(props: { group: string; api: GlobalApi }) { ); @@ -79,13 +79,13 @@ function GraphPermalink( maxWidth={full ? null : '500px'} border={full ? null : '1'} borderColor="lightGray" - borderRadius="2" + borderRadius={2} onClick={(e) => { e.stopPropagation(); }} > {showTransclusion && index && ( - + @@ -136,10 +136,10 @@ function PermalinkDetails(props: { alignItems="center" justifyContent="space-between" width="100%" - px="2" - py="1" + px={2} + py={1} > - + {title} diff --git a/pkg/interface/src/views/apps/permalinks/graphIndex.tsx b/pkg/interface/src/views/apps/permalinks/graphIndex.tsx index 714731e0b3..3d40197ffc 100644 --- a/pkg/interface/src/views/apps/permalinks/graphIndex.tsx +++ b/pkg/interface/src/views/apps/permalinks/graphIndex.tsx @@ -1,4 +1,4 @@ -import { Association, Group } from '@urbit/api'; +import { Association, GraphConfig, Group } from '@urbit/api'; import _ from 'lodash'; import React from 'react'; import { Redirect, Route, Switch } from 'react-router-dom'; @@ -8,7 +8,7 @@ export function getGraphPermalink( group: Group, index: string ) { - const mod = assoc.metadata.config.graph; + const mod = (assoc.metadata.config as GraphConfig).graph; const groupPath = group.hidden ? '/~landscape/home' : `/~landscape${assoc.group}`; diff --git a/pkg/interface/src/views/apps/profile/components/EditProfile.tsx b/pkg/interface/src/views/apps/profile/components/EditProfile.tsx index 2225fa25a0..7705c649c1 100644 --- a/pkg/interface/src/views/apps/profile/components/EditProfile.tsx +++ b/pkg/interface/src/views/apps/profile/components/EditProfile.tsx @@ -1,8 +1,8 @@ import { - Button, Col, ManagedCheckboxField as Checkbox, ManagedForm as Form, - ManagedTextInputField as Input, + Button, Col, ManagedCheckboxField as Checkbox, ManagedForm as Form, + ManagedTextInputField as Input, - Row, Text + Row, Text } from '@tlon/indigo-react'; import { Formik } from 'formik'; import _ from 'lodash'; @@ -18,9 +18,9 @@ import { ColorInput } from '~/views/components/ColorInput'; import GroupSearch from '~/views/components/GroupSearch'; import { ImageInput } from '~/views/components/ImageInput'; import { - ProfileControls, ProfileHeader, + ProfileControls, ProfileHeader, - ProfileImages, ProfileStatus + ProfileImages, ProfileStatus } from './Profile'; const formSchema = Yup.object({ @@ -61,7 +61,7 @@ export function ProfileHeaderImageEdit(props: any): ReactElement { ) : ( - { diff --git a/pkg/interface/src/views/apps/profile/components/Profile.tsx b/pkg/interface/src/views/apps/profile/components/Profile.tsx index 03151887d2..41c73d7784 100644 --- a/pkg/interface/src/views/apps/profile/components/Profile.tsx +++ b/pkg/interface/src/views/apps/profile/components/Profile.tsx @@ -16,7 +16,7 @@ export function ProfileHeader(props: any): ReactElement { @@ -27,7 +27,7 @@ export function ProfileHeader(props: any): ReactElement { export function ProfileImages(props: any): ReactElement { const { hideAvatars } = useSettingsState(selectCalmState); - const { contact, hideCover, ship } = { ...props }; + const { contact, hideCover, ship } = props; const hexColor = contact?.color ? `#${uxToHex(contact.color)}` : '#000000'; const anchorRef = useRef(null); @@ -76,7 +76,7 @@ export function ProfileImages(props: any): ReactElement { + {props.children} ); } export function ProfileStatus(props: any): ReactElement { - const { contact } = { ...props }; + const { contact } = props; return ( {ship === `~${window.ship}` ? ( <> { @@ -145,8 +145,8 @@ export function ProfileActions(props: any): ReactElement { history.push(`/~landscape/dm/${ship.substring(1)}`)} diff --git a/pkg/interface/src/views/apps/profile/components/ViewProfile.tsx b/pkg/interface/src/views/apps/profile/components/ViewProfile.tsx index f63a45927c..7c1122f9fb 100644 --- a/pkg/interface/src/views/apps/profile/components/ViewProfile.tsx +++ b/pkg/interface/src/views/apps/profile/components/ViewProfile.tsx @@ -45,15 +45,15 @@ export function ViewProfile(props: any): ReactElement {
- +
- + {contact?.bio ? contact.bio : ''}
{(contact?.groups || []).length > 0 && ( - + Pinned Groups {contact?.groups.slice().sort(lengthOrder).map(g => ( diff --git a/pkg/interface/src/views/apps/profile/profile.tsx b/pkg/interface/src/views/apps/profile/profile.tsx index ea73638086..3e1faf914b 100644 --- a/pkg/interface/src/views/apps/profile/profile.tsx +++ b/pkg/interface/src/views/apps/profile/profile.tsx @@ -36,7 +36,7 @@ export default function ProfileScreen(props: any) { border={1} borderColor='lightGray' overflowY='auto' - flexGrow + flexGrow={1} > bind.onDragLeave(e)} - onDragOver={(editor, e) => bind.onDragOver(e)} - onDrop={(editor, e) => bind.onDrop(e)} - onDragEnter={(editor, e) => bind.onDragEnter(e)} + onDragLeave={(editor, e: DragEvent) => bind.onDragLeave(e)} + onDragOver={(editor, e: DragEvent) => bind.onDragOver(e)} + onDrop={(editor, e: DragEvent) => bind.onDrop(e)} + onDragEnter={(editor, e: DragEvent) => bind.onDragEnter(e)} /> {dragging && } diff --git a/pkg/interface/src/views/apps/publish/components/MarkdownField.tsx b/pkg/interface/src/views/apps/publish/components/MarkdownField.tsx index 36708880e0..f779b1c6a4 100644 --- a/pkg/interface/src/views/apps/publish/components/MarkdownField.tsx +++ b/pkg/interface/src/views/apps/publish/components/MarkdownField.tsx @@ -36,7 +36,7 @@ export const MarkdownField = ({ value={value} onChange={setValue} /> - + {error}
diff --git a/pkg/interface/src/views/apps/publish/components/Note.tsx b/pkg/interface/src/views/apps/publish/components/Note.tsx index 34ead4b28e..f609c63af1 100644 --- a/pkg/interface/src/views/apps/publish/components/Note.tsx +++ b/pkg/interface/src/views/apps/publish/components/Note.tsx @@ -1,18 +1,18 @@ -import React, { useState, useEffect } from 'react'; -import { Box, Text, Col, Anchor, Row, Action } from '@tlon/indigo-react'; +import { Action, Anchor, Box, Col, Row, Text } from '@tlon/indigo-react'; +import { Association, Graph, GraphNode, Group } from '@urbit/api'; import bigInt from 'big-integer'; +import React, { useEffect, useState } from 'react'; import { Link, RouteComponentProps } from 'react-router-dom'; import GlobalApi from '~/logic/api/global'; import { roleForShip } from '~/logic/lib/group'; -import { Contacts, GraphNode, Graph, Association, Unreads, Group, Post } from '@urbit/api'; import { getPermalinkForGraph } from '~/logic/lib/permalinks'; -import { GraphContent } from '~/views/landscape/components/Graph/GraphContent'; import { getComments, getLatestRevision } from '~/logic/lib/publish'; import { useCopy } from '~/logic/lib/useCopy'; import { useQuery } from '~/logic/lib/useQuery'; import Author from '~/views/components/Author'; import { Comments } from '~/views/components/Comments'; import { Spinner } from '~/views/components/Spinner'; +import { GraphContent } from '~/views/landscape/components/Graph/GraphContent'; import { NoteNavigation } from './NoteNavigation'; import { Redirect } from 'react-router-dom'; @@ -117,7 +117,7 @@ export function Note(props: NoteProps & RouteComponentProps) { date={post?.['time-sent']} group={group} > - + {copyDisplay} {adminLinks} @@ -128,8 +128,7 @@ export function Note(props: NoteProps & RouteComponentProps) { @@ -48,12 +48,12 @@ function getAdjacentId( return target?.[0] || null; } -function makeNoteUrl(noteId: number) { +function makeNoteUrl(noteId: BigInteger) { return noteId.toString(); } interface NoteNavigationProps { - noteId: number; + noteId: BigInteger; notebook: Graph; baseUrl: string; } diff --git a/pkg/interface/src/views/apps/publish/components/NotePreview.tsx b/pkg/interface/src/views/apps/publish/components/NotePreview.tsx index fd6178e99f..2e6ebe74b1 100644 --- a/pkg/interface/src/views/apps/publish/components/NotePreview.tsx +++ b/pkg/interface/src/views/apps/publish/components/NotePreview.tsx @@ -6,9 +6,9 @@ import ReactMarkdown from 'react-markdown'; import { Link } from 'react-router-dom'; import styled from 'styled-components'; import { - getComments, - getLatestRevision, - getSnippet + getComments, + getLatestRevision, + getSnippet } from '~/logic/lib/publish'; import useHarkState from '~/logic/state/hark'; import Author from '~/views/components/Author'; @@ -37,7 +37,7 @@ export function NotePreviewContent({ snippet }) { style={{ backgroundSize: 'cover', backgroundPosition: 'center' }} > - +
) }} @@ -86,7 +86,7 @@ export function NotePreview(props: NotePreviewProps) { borderRadius={2} alignItems='flex-start' overflow='hidden' - p='2' + p={2} > {title} @@ -96,7 +96,7 @@ export function NotePreview(props: NotePreviewProps) { - + + {association.metadata?.title} @@ -50,7 +50,7 @@ export function Notebook(props: NotebookProps & RouteComponentProps): ReactEleme - + { return ( Writers - Add additional writers to this notebook + Add additional writers to this notebook { label="" maxLength={undefined} /> - + Submit {writers.length > 0 ? <> - Current writers: - {writers} + Current writers: + {writers} : - + All group members can write to this channel } diff --git a/pkg/interface/src/views/apps/settings/components/lib/BackButton.tsx b/pkg/interface/src/views/apps/settings/components/lib/BackButton.tsx index 88145ebf8f..6218bcd58d 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/BackButton.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/BackButton.tsx @@ -7,7 +7,7 @@ export function BackButton(props: {}) { Landscape Background - - Set an image background + + Set an image background - - Set a hex-based background - + + Set a hex-based background + )} - + diff --git a/pkg/interface/src/views/apps/settings/components/lib/CalmPref.tsx b/pkg/interface/src/views/apps/settings/components/lib/CalmPref.tsx index a3ab0d61dc..b676499160 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/CalmPref.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/CalmPref.tsx @@ -1,7 +1,7 @@ import { - Col, ManagedToggleSwitchField as Toggle, + Col, ManagedToggleSwitchField as Toggle, - Text + Text } from '@tlon/indigo-react'; import { Form, Formik, FormikHelpers } from 'formik'; import React, { useCallback } from 'react'; @@ -75,8 +75,8 @@ export function CalmPrefs(props: {
- - + + CalmEngine diff --git a/pkg/interface/src/views/apps/settings/components/lib/Debug.tsx b/pkg/interface/src/views/apps/settings/components/lib/Debug.tsx index 66ec23c013..e6b6171721 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/Debug.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/Debug.tsx @@ -52,7 +52,7 @@ const StoreDebugger = (props: StoreDebuggerProps) => { backgroundColor='white' color='black' border='1px solid transparent' - borderRadius='2' + borderRadius={2} fontSize={1} placeholder="Drill Down" width="100%" @@ -65,7 +65,7 @@ const StoreDebugger = (props: StoreDebuggerProps) => { } }} /> - {text} + {text} } ); @@ -75,8 +75,8 @@ const DebugPane = () => { return ( <> - - + + Debug Menu diff --git a/pkg/interface/src/views/apps/settings/components/lib/DisplayForm.tsx b/pkg/interface/src/views/apps/settings/components/lib/DisplayForm.tsx index 534e5a6192..e7b16009b8 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/DisplayForm.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/DisplayForm.tsx @@ -1,8 +1,8 @@ import { - Col, + Col, - Label, - ManagedRadioButtonField as Radio, Text + Label, + ManagedRadioButtonField as Radio, Text } from '@tlon/indigo-react'; import { Form, Formik } from 'formik'; import React from 'react'; @@ -89,8 +89,8 @@ export default function DisplayForm(props: DisplayFormProps) { {props => ( - - + + Display Preferences diff --git a/pkg/interface/src/views/apps/settings/components/lib/GroupChannelPicker.tsx b/pkg/interface/src/views/apps/settings/components/lib/GroupChannelPicker.tsx index 59ce838743..3ec7a3c96d 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/GroupChannelPicker.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/GroupChannelPicker.tsx @@ -5,12 +5,12 @@ import { StatelessToggleSwitchField, Text } from '@tlon/indigo-react'; -import { Association, resourceFromPath } from '@urbit/api'; +import { Association, GraphConfig, resourceFromPath } from '@urbit/api'; import { useField } from 'formik'; import _ from 'lodash'; import React, { useEffect, useState } from 'react'; import { isWatching } from '~/logic/lib/hark'; -import { getModuleIcon } from '~/logic/lib/util'; +import { getModuleIcon, GraphModule } from '~/logic/lib/util'; import useGraphState from '~/logic/state/graph'; import useHarkState from '~/logic/state/hark'; import useMetadataState, { useGraphsForGroup } from '~/logic/state/metadata'; @@ -20,7 +20,7 @@ export function GroupChannelPicker(props: {}) { const associations = useMetadataState(s => s.associations); return ( - + {_.map(associations.groups, (assoc: Association, group: string) => ( ))} @@ -62,7 +62,7 @@ function GroupWithChannels(props: { association: Association }) { display="grid" gridTemplateColumns="24px 24px 1fr 24px 24px" gridTemplateRows="auto" - gridGap="2" + gridGap={2} gridTemplateAreas="'arrow icon title graphToggle groupToggle'" > {Object.keys(joinedGroupGraphs).length > 0 && ( @@ -112,17 +112,17 @@ function Channel(props: { association: Association }) { setValue(!value); }; - const icon = getModuleIcon(metadata.config?.graph); + const icon = getModuleIcon((metadata.config as GraphConfig)?.graph as GraphModule); return ( <> -
+
- + {metadata.title} - + diff --git a/pkg/interface/src/views/apps/settings/components/lib/LeapSettings.tsx b/pkg/interface/src/views/apps/settings/components/lib/LeapSettings.tsx index d628c4aa42..5f3c616cda 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/LeapSettings.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/LeapSettings.tsx @@ -1,7 +1,7 @@ import { - Col, + Col, - ManagedCheckboxField, Text + ManagedCheckboxField, Text } from '@tlon/indigo-react'; import { Form, useField, useFormikContext } from 'formik'; import _ from 'lodash'; @@ -9,8 +9,8 @@ import React from 'react'; import GlobalApi from '~/logic/api/global'; import useSettingsState, { selectSettingsState } from '~/logic/state/settings'; import { - LeapCategories, - leapCategories + LeapCategories, + leapCategories } from '~/types'; import { FormikOnBlur } from '~/views/components/FormikOnBlur'; import { ShuffleFields } from '~/views/components/ShuffleFields'; @@ -73,9 +73,9 @@ export function LeapSettings(props: { api: GlobalApi; }) { return ( <> - - - + + + Leap @@ -84,7 +84,7 @@ export function LeapSettings(props: { api: GlobalApi; }) { - + Customize default Leap sections diff --git a/pkg/interface/src/views/apps/settings/components/lib/NotificationPref.tsx b/pkg/interface/src/views/apps/settings/components/lib/NotificationPref.tsx index abed89bb11..2cecbf9da7 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/NotificationPref.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/NotificationPref.tsx @@ -1,7 +1,7 @@ import { - Col, + Col, - ManagedToggleSwitchField as Toggle, Text + ManagedToggleSwitchField as Toggle, Text } from '@tlon/indigo-react'; import { Form, Formik, FormikHelpers } from 'formik'; import _ from 'lodash'; @@ -72,9 +72,9 @@ export function NotificationPreferences(props: { return ( <> - - - + + + Notification Preferences @@ -84,7 +84,7 @@ export function NotificationPreferences(props: { - + - + Activity diff --git a/pkg/interface/src/views/apps/settings/components/lib/S3Form.tsx b/pkg/interface/src/views/apps/settings/components/lib/S3Form.tsx index 4e2b00ce4f..cf07907be5 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/S3Form.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/S3Form.tsx @@ -1,7 +1,7 @@ import { - Anchor, Col, ManagedForm as Form, ManagedTextInputField as Input, + Anchor, Col, ManagedForm as Form, ManagedTextInputField as Input, - Text + Text } from '@tlon/indigo-react'; import { Formik, FormikHelpers } from 'formik'; import React, { ReactElement, useCallback } from 'react'; @@ -47,7 +47,7 @@ export default function S3Form(props: S3FormProps): ReactElement { return ( <> - + - - + + S3 Storage Setup @@ -72,8 +72,8 @@ export default function S3Form(props: S3FormProps): ReactElement { Learn more @@ -94,8 +94,8 @@ export default function S3Form(props: S3FormProps): ReactElement { - - + + S3 Buckets diff --git a/pkg/interface/src/views/apps/settings/components/lib/Security.tsx b/pkg/interface/src/views/apps/settings/components/lib/Security.tsx index 9ad5d06063..1cb273557b 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/Security.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/Security.tsx @@ -1,7 +1,7 @@ import { - Button, - Col, - StatelessCheckboxField, Text + Button, + Col, + StatelessCheckboxField, Text } from '@tlon/indigo-react'; import React, { useState } from 'react'; import GlobalApi from '~/logic/api/global'; @@ -16,8 +16,8 @@ export default function SecuritySettings({ api }: SecuritySettingsProps) { return ( <> - - + + Security Preferences @@ -25,17 +25,17 @@ export default function SecuritySettings({ api }: SecuritySettingsProps) { Manage sessions, login credentials and Landscape access - + Log out of this session - + {allSessions ? 'You will be logged out of all browsers that have currently logged into your Urbit.' : 'You will be logged out of your Urbit on this browser.'} setAllSessions(s => !s)} > diff --git a/pkg/interface/src/views/apps/settings/components/settings.tsx b/pkg/interface/src/views/apps/settings/components/settings.tsx index 158cdef78b..769702e130 100644 --- a/pkg/interface/src/views/apps/settings/components/settings.tsx +++ b/pkg/interface/src/views/apps/settings/components/settings.tsx @@ -10,14 +10,14 @@ export function SettingsItem(props: { const { to, title, description } = props; return ( - + - + {title} {description} @@ -28,9 +28,9 @@ export function SettingsItem(props: { export default function Settings(props: {}) { return ( - - - System Preferences + + + System Preferences Configure and customize Landscape + {children} ); @@ -94,13 +94,13 @@ return; - + System Preferences diff --git a/pkg/interface/src/views/apps/term/api.tsx b/pkg/interface/src/views/apps/term/api.tsx index 8216a771dc..077263efc3 100644 --- a/pkg/interface/src/views/apps/term/api.tsx +++ b/pkg/interface/src/views/apps/term/api.tsx @@ -1,6 +1,9 @@ import _ from 'lodash'; export default class Api { + ship: any; + channel: any; + bindPaths: any[]; constructor(ship, channel) { this.ship = ship; this.channel = channel; @@ -10,7 +13,7 @@ export default class Api { bind(path, method, ship = this.ship, appl = 'herm', success, fail) { this.bindPaths = _.uniq([...this.bindPaths, path]); - window.subscriptionId = this.channel.subscribe(ship, appl, path, + (window as any).subscriptionId = this.channel.subscribe(ship, appl, path, (err) => { fail(err); }, diff --git a/pkg/interface/src/views/apps/term/app.tsx b/pkg/interface/src/views/apps/term/app.tsx index 58f1a0cbaa..cd0ba942f1 100644 --- a/pkg/interface/src/views/apps/term/app.tsx +++ b/pkg/interface/src/views/apps/term/app.tsx @@ -12,6 +12,11 @@ import Store from './store'; import Subscription from './subscription'; class TermApp extends Component { + store: Store; + api: any; + subscription: any; + props: any; + state: any; constructor(props) { super(props); this.store = new Store(); @@ -27,7 +32,7 @@ class TermApp extends Component { componentDidMount() { this.resetControllers(); - const channel = new window.channel(); + const channel = new (window as any).channel(); this.api = new Api(this.props.ship, channel); this.store.api = this.api; @@ -61,13 +66,13 @@ class TermApp extends Component { display='flex' > ; + props: any; constructor(props) { super(props); this.state = {}; @@ -69,7 +71,7 @@ belt = { met: 'bac' }; } paste(e) { - const clipboardData = e.clipboardData || window.clipboardData; + const clipboardData = e.clipboardData || (window as any).clipboardData; const clipboardText = clipboardData.getData('Text'); this.props.api.belt({ txt: [...clipboardText] }); e.preventDefault(); @@ -94,18 +96,18 @@ belt = { met: 'bac' }; } } return ( - - + + { // return ( {text} diff --git a/pkg/interface/src/views/apps/term/store.tsx b/pkg/interface/src/views/apps/term/store.tsx index ebc1bce730..d2166083a4 100644 --- a/pkg/interface/src/views/apps/term/store.tsx +++ b/pkg/interface/src/views/apps/term/store.tsx @@ -2,6 +2,9 @@ import { saveAs } from 'file-saver'; import bel from '../../../logic/lib/bel'; export default class Store { + state: any; + api: any; + setState: any; constructor() { this.state = this.initialState(); } @@ -69,6 +72,7 @@ return h; break; case 'sag': blit.sav = blit.sag; + break; case 'sav': const name = blit.sav.path.split('/').slice(-2).join('.'); const buff = new Buffer(blit.sav.file, 'base64'); diff --git a/pkg/interface/src/views/apps/term/subscription.tsx b/pkg/interface/src/views/apps/term/subscription.tsx index c75c679ae1..178246e43f 100644 --- a/pkg/interface/src/views/apps/term/subscription.tsx +++ b/pkg/interface/src/views/apps/term/subscription.tsx @@ -1,4 +1,8 @@ export default class Subscription { + store: any; + api: any; + channel: any; + firstRoundComplete: boolean; constructor(store, api, channel) { this.store = store; this.api = api; @@ -51,13 +55,13 @@ return; console.error('event source error: ', err); console.log('initiating new channel'); this.firstRoundComplete = false; - setTimeout(2000, () => { + setTimeout(() => { this.store.handleEvent({ data: { clear : true } }); this.start(); - }); + }, 2000); } subscribe(path, app) { diff --git a/pkg/interface/src/views/components/Author.tsx b/pkg/interface/src/views/components/Author.tsx index 58b3abc157..761a5b9853 100644 --- a/pkg/interface/src/views/components/Author.tsx +++ b/pkg/interface/src/views/components/Author.tsx @@ -2,6 +2,7 @@ import { BaseImage, Box, Row } from '@tlon/indigo-react'; import moment from 'moment'; import React, { ReactElement, ReactNode, useState } from 'react'; import { useHistory } from 'react-router-dom'; +import GlobalApi from '~/logic/api/global'; import { Sigil } from '~/logic/lib/sigil'; import { useCopy } from '~/logic/lib/useCopy'; import { cite, deSig, useShowNickname, uxToHex } from '~/logic/lib/util'; @@ -20,7 +21,7 @@ interface AuthorProps { unread?: boolean; api?: GlobalApi; size?: number; - lineHeight?: string; + lineHeight?: string | number; } // eslint-disable-next-line max-lines-per-function @@ -106,7 +107,7 @@ export default function Author(props: AuthorProps & PropFunc): React @@ -93,15 +93,15 @@ export function ChipInput(props: ChipInputProps): ReactElement { }, [inputRef.current, addNewChip, newChip]); return ( - + {caption && } - + {meta.error} diff --git a/pkg/interface/src/views/components/ColorInput.tsx b/pkg/interface/src/views/components/ColorInput.tsx index c947ee9d01..cf68ca0e5d 100644 --- a/pkg/interface/src/views/components/ColorInput.tsx +++ b/pkg/interface/src/views/components/ColorInput.tsx @@ -1,10 +1,10 @@ import { - Box, Col, + Box, Col, - ErrorLabel, Label, - Row, + ErrorLabel, Label, + Row, - StatelessTextInput as Input + StatelessTextInput as Input } from '@tlon/indigo-react'; import { useField } from 'formik'; import React, { FormEvent } from 'react'; @@ -40,11 +40,11 @@ export function ColorInput(props: ColorInputProps) { {caption ? ( - - + {meta.error} diff --git a/pkg/interface/src/views/components/CommentItem.tsx b/pkg/interface/src/views/components/CommentItem.tsx index cb2caa2f98..de8ebd88ab 100644 --- a/pkg/interface/src/views/components/CommentItem.tsx +++ b/pkg/interface/src/views/components/CommentItem.tsx @@ -11,8 +11,8 @@ import { getPermalinkForGraph } from '~/logic/lib/permalinks'; import { getLatestCommentRevision } from '~/logic/lib/publish'; import { useCopy } from '~/logic/lib/useCopy'; import useMetadataState from '~/logic/state/metadata'; -import { GraphContent } from '../landscape/components/Graph/GraphContent'; import Author from '~/views/components/Author'; +import { GraphContent } from '../landscape/components/Graph/GraphContent'; const ClickBox = styled(Box)` cursor: pointer; @@ -60,8 +60,9 @@ export function CommentItem(props: CommentItemProps) { }; const ourMention = post?.contents?.some((e) => { - return e?.mention && e?.mention === window.ship; - }); + if (!('mention' in e)) return false; + return e?.mention && e?.mention === window.ship; + }); if (!highlighted) { if (ourMention) { @@ -118,7 +119,7 @@ export function CommentItem(props: CommentItemProps) { return ( - + - + {copyDisplay} {adminLinks} ) { const post = createPost( content, commentNode.post.index, - parseInt(idx + 1, 10) + parseInt((idx + 1).toString(), 10).toString() ); await api.graph.addPost(ship, name, post); history.push(baseUrl); @@ -128,7 +128,7 @@ export function Comments(props: CommentsProps & PropFunc) { const canComment = isWriter(group, association.resource) || association.metadata.vip === 'reader-comments'; return ( - + {( !editCommentId && canComment ? : null )} {( editCommentId ? ( + {children} diff --git a/pkg/interface/src/views/components/DropdownSearch.tsx b/pkg/interface/src/views/components/DropdownSearch.tsx index 7beda190c8..9141b41d24 100644 --- a/pkg/interface/src/views/components/DropdownSearch.tsx +++ b/pkg/interface/src/views/components/DropdownSearch.tsx @@ -1,14 +1,14 @@ import { - Box, - StatelessTextInput as Input + Box, + StatelessTextInput as Input } from '@tlon/indigo-react'; import _ from 'lodash'; import Mousetrap from 'mousetrap'; import React, { - ChangeEvent, - ReactElement, useCallback, - useEffect, useMemo, useRef, - useState + ChangeEvent, + ReactElement, useCallback, + useEffect, useMemo, useRef, + useState } from 'react'; import { useDropdown } from '~/logic/lib/useDropdown'; import { PropFunc } from '~/types/util'; @@ -140,9 +140,9 @@ export function DropdownSearch(props: DropdownSearchProps): ReactElement { /> {dropdown.length !== 0 && query.length !== 0 && ( { body =`\`\`\`%0A${error.stack?.replaceAll('\n', '%0A')}%0A\`\`\``; } return ( - + {code ? code : 'Error'} diff --git a/pkg/interface/src/views/components/FormGroup.tsx b/pkg/interface/src/views/components/FormGroup.tsx index 6d82ee84a8..84a5cc0910 100644 --- a/pkg/interface/src/views/components/FormGroup.tsx +++ b/pkg/interface/src/views/components/FormGroup.tsx @@ -2,9 +2,9 @@ import { Box, Button, Row } from '@tlon/indigo-react'; import { useFormikContext } from 'formik'; import _ from 'lodash'; import React, { - useCallback, useEffect, + useCallback, useEffect, - useMemo, useState + useMemo, useState } from 'react'; import { Prompt } from 'react-router-dom'; import { FormGroupContext, SubmitHandler } from '~/logic/lib/formGroup'; @@ -152,10 +152,10 @@ export function FormGroup(props: { onReset?: () => void; } & PropFunc diff --git a/pkg/interface/src/views/components/FormSubmit.tsx b/pkg/interface/src/views/components/FormSubmit.tsx index 22f3320f29..ad53f6b3f0 100644 --- a/pkg/interface/src/views/components/FormSubmit.tsx +++ b/pkg/interface/src/views/components/FormSubmit.tsx @@ -22,10 +22,10 @@ export function FormSubmit(props: FormSubmitProps): ReactElement { return ( {dirty && !isSubmitting && ( diff --git a/pkg/interface/src/views/components/GroupLink.tsx b/pkg/interface/src/views/components/GroupLink.tsx index 7716823d64..8388b82740 100644 --- a/pkg/interface/src/views/components/GroupLink.tsx +++ b/pkg/interface/src/views/components/GroupLink.tsx @@ -1,4 +1,5 @@ import { Box, Col, Row, Text } from '@tlon/indigo-react'; +import { MetadataUpdatePreview } from '@urbit/api'; import React, { ReactElement, useEffect, useLayoutEffect, useState } from 'react'; import { useHistory } from 'react-router-dom'; import GlobalApi from '~/logic/api/global'; @@ -56,20 +57,20 @@ onClick={(e) => { width="fit-content" flexShrink={1} alignItems="center" - py="2" - pr="2" + py={2} + pr={2} onClick={ joined ? () => history.push(`/~landscape/ship/${name}`) : showModal } cursor='pointer' opacity={preview ? '1' : '0.6'} > - + - + {preview ? preview.metadata.title : name} - {preview ? `${preview.members} members` : 'Fetching member count'} + {preview ? `${preview.members} members` : 'Fetching member count'} diff --git a/pkg/interface/src/views/components/GroupSearch.tsx b/pkg/interface/src/views/components/GroupSearch.tsx index 0675a73da4..eb4c77f744 100644 --- a/pkg/interface/src/views/components/GroupSearch.tsx +++ b/pkg/interface/src/views/components/GroupSearch.tsx @@ -1,10 +1,10 @@ import { - Box, + Box, - Col, + Col, - ErrorLabel, Icon, Label, - Row, Text + ErrorLabel, Icon, Label, + Row, Text } from '@tlon/indigo-react'; import { Association } from '@urbit/api/metadata'; import { FieldArray, useFormikContext } from 'formik'; @@ -132,12 +132,12 @@ export function GroupSearch>(props: Gr {caption && ( -