Skip to content

Commit

Permalink
chore(web): fix classic notification bar (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaWaite committed Nov 9, 2023
1 parent 0b02908 commit 1ca1531
Show file tree
Hide file tree
Showing 39 changed files with 136 additions and 512 deletions.
2 changes: 1 addition & 1 deletion web/package.json
Expand Up @@ -188,4 +188,4 @@
"use-file-input": "1.0.0",
"uuid": "9.0.1"
}
}
}
@@ -1,4 +1,4 @@
import { ReactNode, useCallback, useState } from "react";
import { ReactNode, useCallback, useRef, useState } from "react";

import TextInput from "@reearth/beta/components/fields/common/TextInput";
import Icon from "@reearth/beta/components/Icon";
Expand Down Expand Up @@ -32,26 +32,31 @@ const LayerStyleCard: React.FC<Props> = ({
const [isHovered, setIsHovered] = useState(false);
const [isEditing, setIsEditing] = useState(false);
const [newName, setNewName] = useState(name);
const [clickTimeoutId, setClickTimeoutId] = useState<any>(null);
const clickTimeoutRef = useRef<NodeJS.Timeout>();
const clickedNameCount = useRef(0);

const handleClick = useCallback(() => {
if (clickTimeoutId !== null) {
clearTimeout(clickTimeoutId);
setClickTimeoutId(null);
console.log(clickedNameCount.current);
if (clickTimeoutRef.current) {
clearTimeout(clickTimeoutRef.current);
}
const timeoutId = window.setTimeout(() => {
clickTimeoutRef.current = setTimeout(() => {
clickedNameCount.current = 0;
onSelect?.(!selected);
}, 200);
setClickTimeoutId(timeoutId);
}, [clickTimeoutId, onSelect, selected]);
}, 100);
}, [onSelect, selected]);

const handleNameClick = useCallback(() => {
if (clickTimeoutId !== null) {
clearTimeout(clickTimeoutId);
setClickTimeoutId(null);
const newClickCount = clickedNameCount.current + 1;
console.log(newClickCount);
clickedNameCount.current = newClickCount;
// if (clickTimeoutRef.current) {
// clearTimeout(clickTimeoutRef.current);
// }
if (clickedNameCount.current === 2) {
setIsEditing(true);
}
setIsEditing(true);
}, [clickTimeoutId]);
}, []);

const handleMouseEnter = useCallback(() => {
setIsHovered(true);
Expand Down
49 changes: 0 additions & 49 deletions web/src/classic/components/atoms/Notification/index.stories.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions web/src/classic/components/atoms/Notification/index.test.tsx

This file was deleted.

95 changes: 0 additions & 95 deletions web/src/classic/components/atoms/Notification/index.tsx

This file was deleted.

Expand Up @@ -3,9 +3,9 @@ import { useCallback, useEffect, useMemo } from "react";
import { useNavigate } from "react-router-dom";

import { useGetTeamsQuery } from "@reearth/classic/gql";
import { useWorkspace, useNotification, useUserId } from "@reearth/classic/state";
import { useAuth, useCleanUrl } from "@reearth/services/auth";
import { useT } from "@reearth/services/i18n";
import { useWorkspace, useNotification, useUserId } from "@reearth/services/state";

export type Mode = "layer" | "widget";

Expand Down
Expand Up @@ -9,8 +9,8 @@ import {
Maybe,
AssetSortType as GQLSortType,
} from "@reearth/classic/gql";
import { useNotification } from "@reearth/classic/state";
import { useT } from "@reearth/services/i18n";
import { useNotification } from "@reearth/services/state";

export type AssetNodes = NonNullable<GetAssetsQuery["assets"]["nodes"][number]>[];

Expand Down
6 changes: 3 additions & 3 deletions web/src/classic/components/organisms/Dashboard/hooks.ts
Expand Up @@ -14,14 +14,14 @@ import {
Visualizer,
GetProjectsQuery,
} from "@reearth/classic/gql";
import { useStorytellingFetcher } from "@reearth/services/api";
import { useT } from "@reearth/services/i18n";
import {
useWorkspace,
useProject,
useUnselectProject,
useNotification,
} from "@reearth/classic/state";
import { useStorytellingFetcher } from "@reearth/services/api";
import { useT } from "@reearth/services/i18n";
} from "@reearth/services/state";
import { ProjectType } from "@reearth/types";

export type ProjectNodes = NonNullable<GetProjectsQuery["projects"]["nodes"][number]>[];
Expand Down
Expand Up @@ -21,6 +21,9 @@ import {
WidgetAreaAlign,
ValueType,
} from "@reearth/classic/gql";
import { valueTypeToGQL, ValueTypes, valueToGQL, LatLng } from "@reearth/classic/util/value";
import { config } from "@reearth/services/config";
import { useLang } from "@reearth/services/i18n";
import {
useSceneId,
useSceneMode,
Expand All @@ -32,10 +35,7 @@ import {
useZoomedLayerId,
useClock,
useSelectedWidgetArea,
} from "@reearth/classic/state";
import { valueTypeToGQL, ValueTypes, valueToGQL, LatLng } from "@reearth/classic/util/value";
import { config } from "@reearth/services/config";
import { useLang } from "@reearth/services/i18n";
} from "@reearth/services/state";

import {
convertWidgets,
Expand Down
Expand Up @@ -12,15 +12,15 @@ import {
useRemoveDatasetMutation,
useGetDatasetSchemasWithCountQuery,
} from "@reearth/classic/gql";
import { useT, useLang } from "@reearth/services/i18n";
import {
useSceneId,
useNotification,
useSelected,
useProject,
NotificationType,
useCurrentTheme,
} from "@reearth/classic/state";
import { useT, useLang } from "@reearth/services/i18n";
} from "@reearth/services/state";

export default () => {
const t = useT();
Expand Down
Expand Up @@ -5,8 +5,8 @@ import {
useGetDatasetsForDatasetInfoPaneQuery,
useGetScenePluginsForDatasetInfoPaneQuery,
} from "@reearth/classic/gql";
import { useNotification, useProject, useRootLayerId, useSelected } from "@reearth/classic/state";
import { useT } from "@reearth/services/i18n";
import { useNotification, useProject, useRootLayerId, useSelected } from "@reearth/services/state";

import { processDatasets, processDatasetHeaders, processPrimitives } from "./convert";

Expand Down
@@ -1,8 +1,8 @@
import { useCallback } from "react";

import { Format } from "@reearth/classic/components/molecules/EarthEditor/ExportPane";
import { useRootLayerId, useSelected } from "@reearth/classic/state";
import { useAuth } from "@reearth/services/auth";
import { useRootLayerId, useSelected } from "@reearth/services/state";

const ext: { [key in Format]: string } = {
kml: "kml",
Expand Down
Expand Up @@ -12,9 +12,9 @@ import {
useCheckProjectAliasLazyQuery,
useCreateTeamMutation,
} from "@reearth/classic/gql";
import { useSceneId, useWorkspace, useProject, useNotification } from "@reearth/classic/state";
import { useAuth } from "@reearth/services/auth";
import { useT } from "@reearth/services/i18n";
import { useSceneId, useWorkspace, useProject, useNotification } from "@reearth/services/state";

export default () => {
const url = window.REEARTH_CONFIG?.published?.split("{}");
Expand Down
@@ -1,4 +1,4 @@
import { useIsCapturing } from "@reearth/classic/state";
import { useIsCapturing } from "@reearth/services/state";

export default () => {
const [isCapturing] = useIsCapturing();
Expand Down
Expand Up @@ -27,6 +27,9 @@ import {
PluginExtensionType,
GetLayersFromLayerIdQuery,
} from "@reearth/classic/gql";
import deepFind from "@reearth/classic/util/deepFind";
import deepGet from "@reearth/classic/util/deepGet";
import { useLang, useT } from "@reearth/services/i18n";
import {
useSceneId,
useSelected,
Expand All @@ -35,10 +38,7 @@ import {
useWidgetAlignEditorActivated,
useZoomedLayerId,
useSelectedWidgetArea,
} from "@reearth/classic/state";
import deepFind from "@reearth/classic/util/deepFind";
import deepGet from "@reearth/classic/util/deepGet";
import { useLang, useT } from "@reearth/services/i18n";
} from "@reearth/services/state";

const convertFormat = (format: Format) => {
if (format === "kml") return LayerEncodingFormat.Kml;
Expand Down
@@ -1,8 +1,8 @@
import { useMemo } from "react";

import { useGetPrimitivesQuery, useAddLayerItemFromPrimitiveMutation } from "@reearth/classic/gql";
import { useSceneId, useSelected } from "@reearth/classic/state";
import { useLang } from "@reearth/services/i18n";
import { useSceneId, useSelected } from "@reearth/services/state";

// ポリゴンやポリラインは現在編集できないため、それらを新規レイヤーとして追加しても何も表示されない
const hiddenExtensions = ["reearth/polyline", "reearth/polygon", "reearth/rect"];
Expand Down
Expand Up @@ -6,7 +6,7 @@ import {
useGetLinkableDatasetsQuery,
useGetLayersFromLayerIdQuery,
} from "@reearth/classic/gql";
import { Selected } from "@reearth/classic/state";
import { Selected } from "@reearth/services/state";

import { convert, Pane, convertLinkableDatasets, convertLayers } from "./convert";

Expand Down

0 comments on commit 1ca1531

Please sign in to comment.