mirror of
https://github.com/mattermost/focalboard.git
synced 2025-02-19 19:59:59 +02:00
update some error handling, update attachments on duplicate card
This commit is contained in:
parent
3fd43aaec1
commit
10b78c5144
@ -311,15 +311,17 @@ func (a *App) CopyCardFiles(sourceBoardID string, copiedBlocks []*model.Block) e
|
||||
for i := range copiedBlocks {
|
||||
block := copiedBlocks[i]
|
||||
fileName := ""
|
||||
isOk := false
|
||||
|
||||
switch block.Type {
|
||||
case model.TypeImage:
|
||||
fileName, _ = block.Fields["fileId"].(string)
|
||||
if fileName == "" {
|
||||
fileName, isOk = block.Fields["fileId"].(string)
|
||||
if !isOk || fileName == "" {
|
||||
continue
|
||||
}
|
||||
case model.TypeAttachment:
|
||||
fileName, _ = block.Fields["attachmentId"].(string)
|
||||
if fileName == "" {
|
||||
fileName, isOk = block.Fields["attachmentId"].(string)
|
||||
if !isOk || fileName == "" {
|
||||
continue
|
||||
}
|
||||
default:
|
||||
@ -360,13 +362,16 @@ func (a *App) CopyCardFiles(sourceBoardID string, copiedBlocks []*model.Block) e
|
||||
block.Fields["attachmentId"] = destFilename
|
||||
parts := strings.Split(fileName, ".")
|
||||
fileInfoID := parts[0][1:]
|
||||
fileInfo, _ := a.store.GetFileInfo(fileInfoID)
|
||||
fileInfo, err := a.store.GetFileInfo(fileInfoID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("CopyCardFiles: cannot retrieve original fileinfo: %w", err)
|
||||
}
|
||||
newParts := strings.Split(destFilename, ".")
|
||||
newFileID := newParts[0][1:]
|
||||
fileInfo.Id = newFileID
|
||||
err := a.store.SaveFileInfo(fileInfo)
|
||||
err = a.store.SaveFileInfo(fileInfo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot create file info for CopyCardFiles: %w", err)
|
||||
return fmt.Errorf("CopyCardFiles: cannot create fileinfo: %w", err)
|
||||
}
|
||||
} else {
|
||||
block.Fields["fileId"] = destFilename
|
||||
|
@ -12,6 +12,7 @@ import {BoardView, ISortOption, createBoardView, KanbanCalculationFields} from '
|
||||
import {Card, createCard} from './blocks/card'
|
||||
import {ContentBlock} from './blocks/contentBlock'
|
||||
import {CommentBlock} from './blocks/commentBlock'
|
||||
import {AttachmentBlock} from './blocks/attachmentBlock'
|
||||
import {FilterGroup} from './blocks/filterGroup'
|
||||
import octoClient from './octoClient'
|
||||
import undoManager from './undomanager'
|
||||
@ -26,6 +27,7 @@ import store from './store'
|
||||
import {updateBoards} from './store/boards'
|
||||
import {updateViews} from './store/views'
|
||||
import {updateCards} from './store/cards'
|
||||
import {updateAttachments} from './store/attachments'
|
||||
import {updateComments} from './store/comments'
|
||||
import {updateContents} from './store/contents'
|
||||
import {addBoardUsers, removeBoardUsersById} from './store/users'
|
||||
@ -35,6 +37,7 @@ function updateAllBoardsAndBlocks(boards: Board[], blocks: Block[]) {
|
||||
store.dispatch(updateBoards(boards.filter((b: Board) => b.deleteAt !== 0) as Board[]))
|
||||
store.dispatch(updateViews(blocks.filter((b: Block) => b.type === 'view' || b.deleteAt !== 0) as BoardView[]))
|
||||
store.dispatch(updateCards(blocks.filter((b: Block) => b.type === 'card' || b.deleteAt !== 0) as Card[]))
|
||||
store.dispatch(updateAttachments(blocks.filter((b: Block) => b.type === 'attachment' || b.deleteAt !== 0) as AttachmentBlock[]))
|
||||
store.dispatch(updateComments(blocks.filter((b: Block) => b.type === 'comment' || b.deleteAt !== 0) as CommentBlock[]))
|
||||
store.dispatch(updateContents(blocks.filter((b: Block) => b.type !== 'card' && b.type !== 'view' && b.type !== 'board' && b.type !== 'comment') as ContentBlock[]))
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user