Skip to content

Commit

Permalink
rename anno store
Browse files Browse the repository at this point in the history
  • Loading branch information
hxhxhx88 committed Feb 20, 2024
1 parent 1a2715b commit e3ed0e4
Show file tree
Hide file tree
Showing 24 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/frontend/src/common/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {v4 as uuidv4} from 'uuid';

import {deepEqual} from 'common/util';
import {EntityComponentId, useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useAnnoStore, getComponent, getSlice} from 'state/annotate/annotation';
import {useAnnoStore, getComponent, getSlice} from 'state/annotate/annotation';
import {useStore as useUIStore} from 'state/annotate/ui';
import {useStore as useDrawPolyStore} from 'state/annotate/polychain/draw';
import {useStore as useDrawRectStore} from 'state/annotate/rectangle/draw';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/common/render.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useCallback} from 'react';

import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';
import {ViewportTransform} from 'state/annotate/render/viewport';

Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/Testing.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {FC, useEffect} from 'react';

import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
export const Testing: FC = () => {
useEffect(() => {
const annoState = useAnnoStore.getState();
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
faChessBoard,
} from '@fortawesome/free-solid-svg-icons';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useTemporalStore as useTemporalAnnoStore} from 'state/annotate/annotation';
import {useTemporalAnnoStore} from 'state/annotate/annotation';
import {useStore as useUIStore} from 'state/annotate/ui';
import {ConfigContext} from 'common/context';
import {rectFitTransform} from 'common/geometry';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/AnnotateLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {FC, useEffect, CSSProperties, useState, HTMLAttributes, useContext} from
import shallow from 'zustand/shallow';
import intl from 'react-intl-universal';

import {useTemporalStore as useTemporalAnnoStore} from 'state/annotate/annotation';
import {useTemporalAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useUIStore} from 'state/annotate/ui';

Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/ContextMenuMask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import intl from 'react-intl-universal';
import {Dropdown, DropdownProps, App, Space, Tag, MenuProps} from 'antd';
import {ExclamationCircleOutlined} from '@ant-design/icons';
import {css} from '@emotion/react';
import {getComponent, useStore as useAnnoStore} from 'state/annotate/annotation';
import {getComponent, useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';
import {ComponentId, EntityId, MaskComponent, PolychainComponent} from 'type/annotation';

Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/entity/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {css} from '@emotion/react';
import {Space, Card, Typography, Button, Popconfirm, Progress, Spin} from 'antd';
import {EditOutlined, DeleteOutlined} from '@ant-design/icons';

import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useUIStore} from 'state/annotate/ui';

Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/entity/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {FC} from 'react';
import intl from 'react-intl-universal';
import {Form, TreeSelect, TreeSelectProps, Space, Tag} from 'antd';

import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';

import {CategoryAbbreviation} from 'component/panel/entity/display';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/entity/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {produce} from 'immer';

import {Alert, Empty, Space, Tag, Tooltip} from 'antd';

import {useStore as useAnnoStore, State} from 'state/annotate/annotation';
import {useAnnoStore, State} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';

import {deepEqual} from 'common/util';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/layer/Hover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import shallow from 'zustand/shallow';
import {Key} from 'ts-key-enum';
import {isHotkeyPressed, useHotkeys} from 'react-hotkeys-hook';

import {useStore as useAnnoStore, getComponent} from 'state/annotate/annotation';
import {useAnnoStore, getComponent} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useUIStore} from 'state/annotate/ui';

Expand Down
4 changes: 2 additions & 2 deletions app/frontend/src/component/panel/layer/Idle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import intl from 'react-intl-universal';
import {v4 as uuidv4} from 'uuid';
import {message} from 'antd';

import {useTemporalStore as useTemporalAnnoStore} from 'state/annotate/annotation';
import {useTemporalAnnoStore} from 'state/annotate/annotation';
import {EntityComponentId, useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useUIStore} from 'state/annotate/ui';
import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {useStore as useEditPolyStore} from 'state/annotate/polychain/edit';
import {useStore as useEditRectStore} from 'state/annotate/rectangle/edit';

Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/layer/Surround.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {FC, CanvasHTMLAttributes, useCallback} from 'react';

import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';

import {useKeyPressed} from 'common/keyboard';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/layer/Translate.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {FC, useCallback, useState, HTMLAttributes, useMemo, useRef} from 'react';
import shallow from 'zustand/shallow';

import {getComponent, useStore as useAnnoStore} from 'state/annotate/annotation';
import {getComponent, useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';
import {TranslateData} from 'state/annotate/render/translate';

Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/layer/mask/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import shallow from 'zustand/shallow';
import {coordinatesImageToCanvas} from 'common/geometry';
import {ViewportTransform} from 'state/annotate/render/viewport';
import {useStore as useRenderStore} from 'state/annotate/render';
import {UpdateSliceMasksInput, useStore as useAnnoStore} from 'state/annotate/annotation';
import {UpdateSliceMasksInput, useAnnoStore} from 'state/annotate/annotation';
import {ComponentId, EntityId, MaskComponent} from 'type/annotation';
import {editStyle} from 'common/constant';
import {ColorPalette} from 'component/panel/entity/display';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/layer/polychain/Draw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import intl from 'react-intl-universal';
import shallow from 'zustand/shallow';
import {v4 as uuidv4} from 'uuid';

import {getComponent, useStore as useAnnoStore} from 'state/annotate/annotation';
import {getComponent, useAnnoStore} from 'state/annotate/annotation';
import {useStore as useUIStore} from 'state/annotate/ui';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useDrawStore, useTemporalStore as useTemporalDrawStore} from 'state/annotate/polychain/draw';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/layer/polychain/Edit.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {FC, useCallback, CanvasHTMLAttributes, useState} from 'react';
import shallow from 'zustand/shallow';

import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useEditStore} from 'state/annotate/polychain/edit';

Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/layer/rectangle/Draw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {editStyle} from 'common/constant';
import {useDrawRect} from 'common/render';
import {coordinatesCanvasToImage, limitCoordinates} from 'common/geometry';

import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useDrawStore} from 'state/annotate/rectangle/draw';
import {ColorPalette} from 'component/panel/entity/display';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/layer/rectangle/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {useDrawRect} from 'common/render';
import {editStyle} from 'common/constant';
import {coordinatesCanvasToImage, limitCoordinates} from 'common/geometry';

import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useEditStore, Data} from 'state/annotate/rectangle/edit';
import {ColorPalette} from 'component/panel/entity/display';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/menu/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {App} from 'antd';
import intl from 'react-intl-universal';
import {v4 as uuidv4} from 'uuid';

import {getSlice, useStore as useAnnoStore} from 'state/annotate/annotation';
import {getSlice, useAnnoStore} from 'state/annotate/annotation';
import {useStore as useRenderStore} from 'state/annotate/render';

import type {EntityId, ComponentId} from 'type/annotation';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/menu/mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {v4 as uuidv4} from 'uuid';
import {Component, EntityId, MaskComponent, SliceIndex} from 'type/annotation';
import {useStore as useUIStore} from 'state/annotate/ui';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {Action} from './common';
import {useCallback, useContext} from 'react';
import {ConfigContext} from 'common/context';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/component/panel/menu/polychain.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import intl from 'react-intl-universal';
import shallow from 'zustand/shallow';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {PolychainComponent} from 'type/annotation';

import {Action} from './common';
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/page/annotate/Panel/Load.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {FC, useContext, useEffect, useState} from 'react';
import intl from 'react-intl-universal';
import {Alert} from 'antd';
import {useStore as useRenderStore} from 'state/annotate/render';
import {useStore as useAnnoStore} from 'state/annotate/annotation';
import {useAnnoStore} from 'state/annotate/annotation';
import {useGetVideoAnnotationYjs} from 'state/server/annotation';
import {useGetVideo} from 'state/server/video';
import {NutshClientContext} from 'common/context';
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/src/state/annotate/annotation-broadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
UpdatePolychainVerticesInput,
UpdateRectangleAnchorsInput,
UpdateSliceMasksInput,
useStore,
useAnnoStore,
} from './annotation';
import {encodeEntityCategoryMapKey, yjsEntityCategoriesMap} from 'common/yjs/docs/entity';
import {useYjsContext} from 'common/yjs/context';
Expand All @@ -36,7 +36,7 @@ import {yjsPolychainVerticesMap} from 'common/yjs/docs/polychain';
import {yjsMaskMap} from 'common/yjs/docs/mask';

export function useAnnoBroadcastStore<K extends keyof StateManipulation>(key: K): StateManipulation[K] {
const fn1 = useStore(s => s[key]);
const fn1 = useAnnoStore(s => s[key]);
const fn2 = useAnnoBroadcast()[key];

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- the input is indeed known byt ts fails to infer
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/src/state/annotate/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export type UpdateSliceMasksInput = {

const emptyAnnotation: Annotation = {entities: {}};

export const useStore = create<State>()(
export const useAnnoStore = create<State>()(
temporal(
subscribeWithSelector(
immer(set => ({
Expand Down Expand Up @@ -418,7 +418,7 @@ export const useStore = create<State>()(
)
);

export const useTemporalStore = create(useStore.temporal);
export const useTemporalAnnoStore = create(useAnnoStore.temporal);

function addComponent(s: State, sliceIndex: SliceIndex, entityId: EntityId, component: Component) {
addAnnotationComponent(s.annotation, sliceIndex, entityId, component);
Expand Down

0 comments on commit e3ed0e4

Please sign in to comment.