1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-24 08:22:29 +02:00

Fix #945. Hydrate blocks on get (#946)

This commit is contained in:
Chen-I Lim 2021-08-12 02:39:02 -07:00 committed by GitHub
parent 994ed01b49
commit 9e70a41ac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
import {Block, BlockPatch} from './blocks/block'
import {ISharing} from './blocks/sharing'
import {IWorkspace} from './blocks/workspace'
import {OctoUtils} from './octoUtils'
import {IUser} from './user'
import {Utils} from './utils'
@ -131,8 +132,7 @@ class OctoClient {
return []
}
const blocks = (await this.getJson(response, [])) as Block[]
this.fixBlocks(blocks)
return blocks
return this.fixBlocks(blocks)
}
// If no boardID is provided, it will export the entire archive
@ -143,8 +143,7 @@ class OctoClient {
return []
}
const blocks = (await this.getJson(response, [])) as Block[]
this.fixBlocks(blocks)
return blocks
return this.fixBlocks(blocks)
}
async importFullArchive(blocks: readonly Block[]): Promise<Response> {
@ -187,17 +186,19 @@ class OctoClient {
return []
}
const blocks = (await this.getJson(response, [])) as Block[]
this.fixBlocks(blocks)
return blocks
return this.fixBlocks(blocks)
}
// TODO: Remove this fixup code
fixBlocks(blocks: Block[]): void {
fixBlocks(blocks: Block[]): Block[] {
if (!blocks) {
return
return []
}
for (const block of blocks) {
// Hydrate is important, as it ensures that each block is complete to the current model
const fixedBlocks = OctoUtils.hydrateBlocks(blocks)
// TODO: Remove this fixup code
for (const block of fixedBlocks) {
if (!block.fields) {
block.fields = {}
}
@ -216,6 +217,8 @@ class OctoClient {
}
}
}
return fixedBlocks
}
async updateBlock(block: Block): Promise<Response> {