Skip to content

Commit

Permalink
refactor: [skip ci] Refactor TodayTaskModal component and fix block
Browse files Browse the repository at this point in the history
UUIDs
  • Loading branch information
haydenull committed Dec 7, 2023
1 parent 6328664 commit 32ed54e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
15 changes: 6 additions & 9 deletions src/components/TodayTaskModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@ const TodayTaskModal: React.FC<{
}
}
const onClickOk = async () => {
const blockList: BlockEntity[] = []
for (let i = 0; i < value.length; i++) {
const block = await getBlockData({ uuid: value[i] })
await fixedBlockUUID(value[i])
blockList.push(block)
}
logseq.Editor.insertBatchBlock(
const blockUUIDList: string[] = value
const fixedBlockPromises = blockUUIDList.map(fixedBlockUUID)
await Promise.all(fixedBlockPromises)
await logseq.Editor.insertBatchBlock(
uuid,
blockList.map((block) => ({
content: `((${block?.uuid}))`,
blockUUIDList.map((_uuid) => ({
content: `((${_uuid}))`,
})),
{
before: false,
Expand Down
4 changes: 1 addition & 3 deletions src/util/logseq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,5 @@ export const navToPage = async (block: BlockEntity) => {
* fixed block uuid
*/
export const fixedBlockUUID = async (blockUUID: string) => {
const isFixed = await logseq.Editor.getBlockProperty(blockUUID, 'id')
if (isFixed) return
logseq.Editor.upsertBlockProperty(blockUUID, 'id', blockUUID)
return logseq.Editor.upsertBlockProperty(blockUUID, 'id', blockUUID)
}

0 comments on commit 32ed54e

Please sign in to comment.