规避数据为空出现的异常

Signed-off-by: nobbo <gaoshang22@huawei.com>
This commit is contained in:
nobbo
2023-06-20 20:06:53 +08:00
parent 40c8737bbf
commit 8577e7e91e
4 changed files with 69 additions and 35 deletions
@@ -98,7 +98,14 @@ export class FolderUtil {
* @return boolean - fottom fixed folder: deleted or favorite return true. else return false
*/
isBottomFixedFolder(folderData: FolderData): boolean {
LogUtil.info(TAG, "folderDataUuid " + folderData.uuid)
if (folderData === undefined || folderData === null) {
LogUtil.info(TAG, "isBottomFixedFolder folderData undefined")
}
if (folderData.uuid === undefined || folderData.uuid === null) {
LogUtil.info(TAG, "isBottomFixedFolder folderData uuid undefined")
folderData.uuid = 'sys_def_unClassified_uuid';
}
LogUtil.info(TAG, "isBottomFixedFolder folderDataUuid " + folderData.uuid)
return (folderData.folder_type == FolderType.FeatureDef)
}
@@ -109,7 +116,14 @@ export class FolderUtil {
* @return boolean - can be moved into notes return true. else return false
*/
isFolderMoveIn(folderData: FolderData): boolean {
LogUtil.info(TAG, "folderDataUuid " + folderData.uuid)
if (folderData === undefined || folderData === null) {
LogUtil.info(TAG, "isFolderMoveIn folderData undefined")
}
if (folderData.uuid === undefined || folderData.uuid === null) {
LogUtil.info(TAG, "isFolderMoveIn folderData uuid undefined")
folderData.uuid = 'sys_def_unClassified_uuid';
}
LogUtil.info(TAG, "isFolderMoveIn folderDataUuid " + folderData.uuid)
return (folderData.uuid == SysDefFolderUuid.UnClassified || folderData.folder_type == FolderType.CusDef)
}
@@ -332,6 +332,10 @@ export struct NoteDataMoveDialog {
aboutToAppear() {
this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length);
if (this.AllFolderArray[1] === undefined || this.AllFolderArray[1] === null) {
LogUtil.info(TAG, "this AllFolderArray[1] undefined")
return
}
this.NoteDataMoveArray.push(this.AllFolderArray[1]);
}
@@ -346,15 +350,17 @@ export struct NoteDataMoveDialog {
.width(288)
List() {
ForEach(this.NoteDataMoveArray.slice(0, this.NoteDataMoveArray.length - 1), (item) => {
ListItem() {
NoteDataMoveItemComp({ folderItem: item })
}
.onClick(() => {
this.noteDataMoveDialogCtl.close()
this.onConfirm(item.uuid)
})
}, noteItem => noteItem.uuid)
if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null && this.NoteDataMoveArray !== []) {
ForEach(this.NoteDataMoveArray.slice(0, this.NoteDataMoveArray.length - 1), (item) => {
ListItem() {
NoteDataMoveItemComp({ folderItem: item })
}
.onClick(() => {
this.noteDataMoveDialogCtl.close()
this.onConfirm(item.uuid)
})
}, noteItem => noteItem.uuid)
}
ListItem() {
NoteDataMoveItemComp({
folderItem: this.NoteDataMoveArray[this.NoteDataMoveArray.length - 1],
@@ -349,11 +349,19 @@ export struct NoteContentOverViewComp {
getArray() {
this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length);
if (this.AllFolderArray[1] === undefined || this.AllFolderArray[1] === null) {
LogUtil.info(TAG, "this AllFolderArray[1] undefined")
return
}
this.NoteDataMoveArray.push(this.AllFolderArray[1]);
}
aboutToAppear() {
this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length);
if (this.AllFolderArray[1] === undefined || this.AllFolderArray[1] === null) {
LogUtil.info(TAG, "this AllFolderArray[1] undefined")
return
}
this.NoteDataMoveArray.push(this.AllFolderArray[1]);
}
@@ -369,31 +377,33 @@ export struct NoteContentOverViewComp {
@Builder MenuBuilder() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
List() {
ForEach(this.NoteDataMoveArray, (item) => {
ListItem() {
NoteDataMoveItemCompTablet({ folderItem: item, uuid: this.selectedNoteData.folder_uuid })
}
.onClick(() => {
this.selectedNoteData.folder_uuid = item.uuid
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
if (this.sectionStatus != 1) {
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)
this.controllerShow.runJavaScript(
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
)
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
} else {
this.selectedFolderData = FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), item.uuid)
if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null && this.NoteDataMoveArray !== []) {
ForEach(this.NoteDataMoveArray, (item) => {
ListItem() {
NoteDataMoveItemCompTablet({ folderItem: item, uuid: this.selectedNoteData.folder_uuid })
}
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
LogUtil.info(TAG, "NoteContentOverViewComp, MenuBuilder, set continue note success")
NoteUtil.refreshAll()
})
}, noteItem => noteItem.uuid)
.onClick(() => {
this.selectedNoteData.folder_uuid = item.uuid
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
if (this.sectionStatus != 1) {
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)
this.controllerShow.runJavaScript(
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
)
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
} else {
this.selectedFolderData = FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), item.uuid)
}
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
LogUtil.info(TAG, "NoteContentOverViewComp, MenuBuilder, set continue note success")
NoteUtil.refreshAll()
})
}, noteItem => noteItem.uuid)
}
}.listDirection(Axis.Vertical)
.edgeEffect(EdgeEffect.Spring)
.height(this.AllFolderArray.length > 12 ? 504 : (this.AllFolderArray.length - 3) * 56)
@@ -363,6 +363,10 @@ export struct NoteContentOverViewComp {
aboutToAppear() {
this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length);
if (this.AllFolderArray[1] === undefined || this.AllFolderArray[1] === null) {
LogUtil.info(TAG, "this AllFolderArray[1] undefined")
return
}
this.NoteDataMoveArray.push(this.AllFolderArray[1]);
}