Skip to content

Commit

Permalink
Merge pull request #323 from Gemini2035/perf/sheetAbout
Browse files Browse the repository at this point in the history
Perf/sheet about
  • Loading branch information
guansss authored Aug 4, 2024
2 parents 7344538 + ca1994e commit b4a125d
Show file tree
Hide file tree
Showing 22 changed files with 2,085 additions and 1,259 deletions.
1 change: 1 addition & 0 deletions scripts/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export async function getOperators() {
return [
{
id: id,
prof: op.profession,
subProf: op.subProfessionId,
...transformOperatorName(op.name),
rarity:
Expand Down
18 changes: 9 additions & 9 deletions src/components/editor/operator/EditorPerformer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,6 @@ export const EditorPerformer: FC<EditorPerformerProps> = ({ control }) => {
setError,
fromSheet,
) => {
const removeOperatorByArray = () =>
removeOperator(
group.opers
?.map((item) => operators.findIndex(({ name }) => name === item.name))
.filter((item) => item !== -1),
)

if (
groups.find(({ name, _id }) => name === group.name && _id !== group._id)
) {
Expand All @@ -331,7 +324,6 @@ export const EditorPerformer: FC<EditorPerformerProps> = ({ control }) => {
: findGroupById(getId(editingGroup!))
if (existingGroup) {
group._id = getId(existingGroup)
if (fromSheet) removeOperatorByArray()
updateGroup(
groups.findIndex(({ _id }) => _id === existingGroup._id),
group,
Expand All @@ -344,7 +336,15 @@ export const EditorPerformer: FC<EditorPerformerProps> = ({ control }) => {
} else {
group._id = uniqueId()
appendGroup(group)
if (group.opers?.length) removeOperatorByArray()
if (group.opers?.length) {
removeOperator(
group.opers
?.map((item) =>
operators.findIndex(({ name }) => name === item.name),
)
.filter((item) => item !== -1),
)
}
}

return true
Expand Down
20 changes: 10 additions & 10 deletions src/components/editor/operator/EditorSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { FC, useState } from 'react'

import { CopilotDocV1 } from 'models/copilot.schema'

import { SheetGroupContainer, SheetGroupProps } from './sheet/SheetGroup'
import {
SheetOperatorContainer,
SheetOperatorProps,
} from './sheet/SheetOperator'
import { SheetGroupContainer } from './sheet/SheetGroup'
import { SheetOperatorContainer } from './sheet/SheetOperator'
import { SheetProvider, SheetProviderProp } from './sheet/SheetProvider'

type EditorSheetProps = SheetOperatorProps & SheetGroupProps
type EditorSheetProps = Omit<SheetProviderProp, 'children'>
export type Group = CopilotDocV1.Group
export type Operator = CopilotDocV1.Operator

const EditorOperatorSheet = (sheetProps: EditorSheetProps) => (
<article className="overflow-y-auto">
<SheetOperatorContainer {...sheetProps} />
<SheetGroupContainer {...sheetProps} />
</article>
<SheetProvider {...sheetProps}>
<article className="overflow-y-auto">
<SheetOperatorContainer />
<SheetGroupContainer />
</article>
</SheetProvider>
)

export const EditorSheetTrigger: FC<EditorSheetProps> = (sheetProps) => {
Expand Down
Loading

0 comments on commit b4a125d

Please sign in to comment.