refactor: move vm hooks into view model folder (#31832)
This commit is contained in:
@@ -10,7 +10,7 @@ import { fn } from "storybook/test";
|
|||||||
|
|
||||||
import type { Meta, StoryFn } from "@storybook/react-vite";
|
import type { Meta, StoryFn } from "@storybook/react-vite";
|
||||||
import { AudioPlayerView, type AudioPlayerViewActions, type AudioPlayerViewSnapshot } from "./AudioPlayerView";
|
import { AudioPlayerView, type AudioPlayerViewActions, type AudioPlayerViewSnapshot } from "./AudioPlayerView";
|
||||||
import { useMockedViewModel } from "../../useMockedViewModel";
|
import { useMockedViewModel } from "../../viewmodel";
|
||||||
|
|
||||||
type AudioPlayerProps = AudioPlayerViewSnapshot & AudioPlayerViewActions;
|
type AudioPlayerProps = AudioPlayerViewSnapshot & AudioPlayerViewActions;
|
||||||
const AudioPlayerViewWrapper = ({ togglePlay, onKeyDown, onSeekbarChange, ...rest }: AudioPlayerProps): JSX.Element => {
|
const AudioPlayerViewWrapper = ({ togglePlay, onKeyDown, onSeekbarChange, ...rest }: AudioPlayerProps): JSX.Element => {
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
|
|
||||||
import React, { type ChangeEventHandler, type JSX, type KeyboardEventHandler, type MouseEventHandler } from "react";
|
import React, { type ChangeEventHandler, type JSX, type KeyboardEventHandler, type MouseEventHandler } from "react";
|
||||||
|
|
||||||
import { type ViewModel } from "../../viewmodel/ViewModel";
|
import { type ViewModel, useViewModel } from "../../viewmodel";
|
||||||
import { useViewModel } from "../../useViewModel";
|
|
||||||
import { MediaBody } from "../../message-body/MediaBody";
|
import { MediaBody } from "../../message-body/MediaBody";
|
||||||
import { Flex } from "../../utils/Flex";
|
import { Flex } from "../../utils/Flex";
|
||||||
import styles from "./AudioPlayerView.module.css";
|
import styles from "./AudioPlayerView.module.css";
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import { type Meta, type StoryFn } from "@storybook/react-vite";
|
|||||||
import React, { type JSX } from "react";
|
import React, { type JSX } from "react";
|
||||||
import { fn } from "storybook/test";
|
import { fn } from "storybook/test";
|
||||||
|
|
||||||
import { useMockedViewModel } from "../../useMockedViewModel";
|
import { useMockedViewModel } from "../../viewmodel";
|
||||||
import {
|
import {
|
||||||
HistoryVisibleBannerView,
|
HistoryVisibleBannerView,
|
||||||
type HistoryVisibleBannerViewActions,
|
type HistoryVisibleBannerViewActions,
|
||||||
|
|||||||
+1
-2
@@ -8,9 +8,8 @@
|
|||||||
import { Link } from "@vector-im/compound-web";
|
import { Link } from "@vector-im/compound-web";
|
||||||
import React, { type JSX } from "react";
|
import React, { type JSX } from "react";
|
||||||
|
|
||||||
import { useViewModel } from "../../useViewModel";
|
|
||||||
import { _t } from "../../utils/i18n";
|
import { _t } from "../../utils/i18n";
|
||||||
import { type ViewModel } from "../../viewmodel";
|
import { type ViewModel, useViewModel } from "../../viewmodel";
|
||||||
import { Banner } from "../Banner";
|
import { Banner } from "../Banner";
|
||||||
|
|
||||||
export interface HistoryVisibleBannerViewActions {
|
export interface HistoryVisibleBannerViewActions {
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ Please see LICENSE files in the repository root for full details.
|
|||||||
|
|
||||||
import React, { type ReactNode, type JSX } from "react";
|
import React, { type ReactNode, type JSX } from "react";
|
||||||
|
|
||||||
import { type ViewModel } from "../../viewmodel/ViewModel";
|
import { type ViewModel, useViewModel } from "../../viewmodel";
|
||||||
import { useViewModel } from "../../useViewModel";
|
|
||||||
|
|
||||||
export type TextualEventViewSnapshot = {
|
export type TextualEventViewSnapshot = {
|
||||||
content: string | ReactNode;
|
content: string | ReactNode;
|
||||||
|
|||||||
@@ -36,5 +36,3 @@ export * from "./utils/I18nApi";
|
|||||||
|
|
||||||
// MVVM
|
// MVVM
|
||||||
export * from "./viewmodel";
|
export * from "./viewmodel";
|
||||||
export * from "./useMockedViewModel";
|
|
||||||
export * from "./useViewModel";
|
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ import {
|
|||||||
type RoomListHeaderViewActions,
|
type RoomListHeaderViewActions,
|
||||||
type RoomListHeaderViewSnapshot,
|
type RoomListHeaderViewSnapshot,
|
||||||
} from "./RoomListHeaderView";
|
} from "./RoomListHeaderView";
|
||||||
import { useMockedViewModel } from "../../useMockedViewModel";
|
import { useMockedViewModel } from "../../viewmodel";
|
||||||
import { defaultSnapshot } from "./default-snapshot";
|
import { defaultSnapshot } from "./default-snapshot";
|
||||||
|
|
||||||
type RoomListHeaderProps = RoomListHeaderViewSnapshot & RoomListHeaderViewActions;
|
type RoomListHeaderProps = RoomListHeaderViewSnapshot & RoomListHeaderViewActions;
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import React, { type JSX } from "react";
|
|||||||
import { IconButton, H1 } from "@vector-im/compound-web";
|
import { IconButton, H1 } from "@vector-im/compound-web";
|
||||||
import ComposeIcon from "@vector-im/compound-design-tokens/assets/web/icons/compose";
|
import ComposeIcon from "@vector-im/compound-design-tokens/assets/web/icons/compose";
|
||||||
|
|
||||||
import { type ViewModel } from "../../viewmodel/ViewModel";
|
import { type ViewModel, useViewModel } from "../../viewmodel";
|
||||||
import { useViewModel } from "../../useViewModel";
|
|
||||||
import { Flex } from "../../utils/Flex";
|
import { Flex } from "../../utils/Flex";
|
||||||
import { useI18n } from "../../utils/i18nContext";
|
import { useI18n } from "../../utils/i18nContext";
|
||||||
import { ComposeMenuView, OptionMenuView, SpaceMenuView } from "./menu";
|
import { ComposeMenuView, OptionMenuView, SpaceMenuView } from "./menu";
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ import RoomIcon from "@vector-im/compound-design-tokens/assets/web/icons/room";
|
|||||||
|
|
||||||
import { type RoomListHeaderViewModel } from "../RoomListHeaderView";
|
import { type RoomListHeaderViewModel } from "../RoomListHeaderView";
|
||||||
import { useI18n } from "../../../utils/i18nContext";
|
import { useI18n } from "../../../utils/i18nContext";
|
||||||
import { useViewModel } from "../../../useViewModel";
|
import { useViewModel } from "../../../viewmodel";
|
||||||
|
|
||||||
interface ComposeMenuViewProps {
|
interface ComposeMenuViewProps {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import React, { type JSX, useState } from "react";
|
|||||||
import OverflowHorizontalIcon from "@vector-im/compound-design-tokens/assets/web/icons/overflow-horizontal";
|
import OverflowHorizontalIcon from "@vector-im/compound-design-tokens/assets/web/icons/overflow-horizontal";
|
||||||
|
|
||||||
import { type RoomListHeaderViewModel } from "../RoomListHeaderView";
|
import { type RoomListHeaderViewModel } from "../RoomListHeaderView";
|
||||||
import { useViewModel } from "../../../useViewModel";
|
import { useViewModel } from "../../../viewmodel";
|
||||||
import { useI18n } from "../../../utils/i18nContext";
|
import { useI18n } from "../../../utils/i18nContext";
|
||||||
import styles from "./OptionMenuView.module.css";
|
import styles from "./OptionMenuView.module.css";
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import PreferencesIcon from "@vector-im/compound-design-tokens/assets/web/icons/
|
|||||||
import UserAddIcon from "@vector-im/compound-design-tokens/assets/web/icons/user-add";
|
import UserAddIcon from "@vector-im/compound-design-tokens/assets/web/icons/user-add";
|
||||||
|
|
||||||
import styles from "./SpaceMenuView.module.css";
|
import styles from "./SpaceMenuView.module.css";
|
||||||
import { useViewModel } from "../../../useViewModel";
|
import { useViewModel } from "../../../viewmodel";
|
||||||
import { useI18n } from "../../../utils/i18nContext";
|
import { useI18n } from "../../../utils/i18nContext";
|
||||||
import { type RoomListHeaderViewModel } from "../RoomListHeaderView";
|
import { type RoomListHeaderViewModel } from "../RoomListHeaderView";
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ import {
|
|||||||
type RoomListSearchViewActions,
|
type RoomListSearchViewActions,
|
||||||
type RoomListSearchViewSnapshot,
|
type RoomListSearchViewSnapshot,
|
||||||
} from "./RoomListSearchView";
|
} from "./RoomListSearchView";
|
||||||
import { useMockedViewModel } from "../../useMockedViewModel";
|
import { useMockedViewModel } from "../../viewmodel";
|
||||||
|
|
||||||
type RoomListSearchProps = RoomListSearchViewSnapshot & RoomListSearchViewActions;
|
type RoomListSearchProps = RoomListSearchViewSnapshot & RoomListSearchViewActions;
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ import SearchIcon from "@vector-im/compound-design-tokens/assets/web/icons/searc
|
|||||||
import DialPadIcon from "@vector-im/compound-design-tokens/assets/web/icons/dial-pad";
|
import DialPadIcon from "@vector-im/compound-design-tokens/assets/web/icons/dial-pad";
|
||||||
|
|
||||||
import styles from "./RoomListSearchView.module.css";
|
import styles from "./RoomListSearchView.module.css";
|
||||||
import { type ViewModel } from "../../viewmodel/ViewModel";
|
import { type ViewModel, useViewModel } from "../../viewmodel";
|
||||||
import { useViewModel } from "../../useViewModel";
|
|
||||||
import { Flex } from "../../utils/Flex";
|
import { Flex } from "../../utils/Flex";
|
||||||
import { useI18n } from "../../utils/i18nContext";
|
import { useI18n } from "../../utils/i18nContext";
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { type Meta, type StoryFn } from "@storybook/react-vite";
|
|||||||
import React, { type JSX } from "react";
|
import React, { type JSX } from "react";
|
||||||
import { fn } from "storybook/test";
|
import { fn } from "storybook/test";
|
||||||
|
|
||||||
import { useMockedViewModel } from "../../useMockedViewModel";
|
import { useMockedViewModel } from "../../viewmodel";
|
||||||
import {
|
import {
|
||||||
RoomStatusBarState,
|
RoomStatusBarState,
|
||||||
RoomStatusBarView,
|
RoomStatusBarView,
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import { RestartIcon, DeleteIcon } from "@vector-im/compound-design-tokens/asset
|
|||||||
import { Button, InlineSpinner, Text } from "@vector-im/compound-web";
|
import { Button, InlineSpinner, Text } from "@vector-im/compound-web";
|
||||||
|
|
||||||
import styles from "./RoomStatusBarView.module.css";
|
import styles from "./RoomStatusBarView.module.css";
|
||||||
import { useViewModel } from "../../useViewModel";
|
import { type ViewModel, useViewModel } from "../../viewmodel";
|
||||||
import { type ViewModel } from "../../viewmodel";
|
|
||||||
import { useI18n } from "../../utils/i18nContext";
|
import { useI18n } from "../../utils/i18nContext";
|
||||||
import { Banner } from "../../composer/Banner";
|
import { Banner } from "../../composer/Banner";
|
||||||
export interface RoomStatusBarViewActions {
|
export interface RoomStatusBarViewActions {
|
||||||
|
|||||||
@@ -12,3 +12,5 @@ export * from "./ViewModelSubscriptions";
|
|||||||
export type * from "./ViewModel";
|
export type * from "./ViewModel";
|
||||||
export * from "./MockViewModel";
|
export * from "./MockViewModel";
|
||||||
export * from "./useCreateAutoDisposedViewModel";
|
export * from "./useCreateAutoDisposedViewModel";
|
||||||
|
export * from "./useViewModel";
|
||||||
|
export * from "./useMockedViewModel";
|
||||||
|
|||||||
+2
-1
@@ -7,7 +7,8 @@
|
|||||||
|
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
|
|
||||||
import { MockViewModel, type ViewModel } from "./viewmodel";
|
import { MockViewModel } from "./MockViewModel";
|
||||||
|
import { type ViewModel } from "./ViewModel";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook helper to return a mocked view model created with the given snapshot and actions.
|
* Hook helper to return a mocked view model created with the given snapshot and actions.
|
||||||
+1
-1
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
|
|||||||
|
|
||||||
import { useSyncExternalStore } from "react";
|
import { useSyncExternalStore } from "react";
|
||||||
|
|
||||||
import { type ViewModel } from "./viewmodel/ViewModel";
|
import { type ViewModel } from "./ViewModel";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A small wrapper around useSyncExternalStore to use a view model in a shared component view
|
* A small wrapper around useSyncExternalStore to use a view model in a shared component view
|
||||||
Reference in New Issue
Block a user