mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-30 00:29:46 +08:00
chore: clean code
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
import { useCallback } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import { useRecastBlock } from './Context';
|
import { useRecastBlock } from './Context';
|
||||||
import {
|
import {
|
||||||
META_VIEWS_KEY,
|
META_VIEWS_KEY,
|
||||||
@@ -17,7 +17,7 @@ const genViewId = () => nanoid(16) as RecastViewId; // This is a safe type cast
|
|||||||
const DEFAULT_VIEWS: RecastView[] = [
|
const DEFAULT_VIEWS: RecastView[] = [
|
||||||
{
|
{
|
||||||
id: genViewId(),
|
id: genViewId(),
|
||||||
name: 'ToDo List',
|
name: 'List',
|
||||||
type: RecastScene.Page,
|
type: RecastScene.Page,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -31,8 +31,9 @@ export const useRecastView = () => {
|
|||||||
const recastBlock = useRecastBlock();
|
const recastBlock = useRecastBlock();
|
||||||
const recastViews =
|
const recastViews =
|
||||||
recastBlock.getProperty(META_VIEWS_KEY) ?? DEFAULT_VIEWS;
|
recastBlock.getProperty(META_VIEWS_KEY) ?? DEFAULT_VIEWS;
|
||||||
|
|
||||||
// TODO save cur view
|
// TODO save cur view
|
||||||
const currentView = recastViews[0];
|
const [currentView, changeView] = useState(recastViews[0]);
|
||||||
|
|
||||||
const getView = useCallback(
|
const getView = useCallback(
|
||||||
(id: RecastViewId) => {
|
(id: RecastViewId) => {
|
||||||
@@ -117,6 +118,7 @@ export const useRecastView = () => {
|
|||||||
return {
|
return {
|
||||||
currentView,
|
currentView,
|
||||||
recastViews,
|
recastViews,
|
||||||
|
changeView,
|
||||||
addView,
|
addView,
|
||||||
updateView,
|
updateView,
|
||||||
renameView,
|
renameView,
|
||||||
|
|||||||
Reference in New Issue
Block a user