规避数据为空出现的异常

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 * @return boolean - fottom fixed folder: deleted or favorite return true. else return false
*/ */
isBottomFixedFolder(folderData: FolderData): boolean { 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) 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 * @return boolean - can be moved into notes return true. else return false
*/ */
isFolderMoveIn(folderData: FolderData): boolean { 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) return (folderData.uuid == SysDefFolderUuid.UnClassified || folderData.folder_type == FolderType.CusDef)
} }
@@ -332,6 +332,10 @@ export struct NoteDataMoveDialog {
aboutToAppear() { aboutToAppear() {
this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length); 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]); this.NoteDataMoveArray.push(this.AllFolderArray[1]);
} }
@@ -346,15 +350,17 @@ export struct NoteDataMoveDialog {
.width(288) .width(288)
List() { List() {
ForEach(this.NoteDataMoveArray.slice(0, this.NoteDataMoveArray.length - 1), (item) => { if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null && this.NoteDataMoveArray !== []) {
ListItem() { ForEach(this.NoteDataMoveArray.slice(0, this.NoteDataMoveArray.length - 1), (item) => {
NoteDataMoveItemComp({ folderItem: item }) ListItem() {
} NoteDataMoveItemComp({ folderItem: item })
.onClick(() => { }
this.noteDataMoveDialogCtl.close() .onClick(() => {
this.onConfirm(item.uuid) this.noteDataMoveDialogCtl.close()
}) this.onConfirm(item.uuid)
}, noteItem => noteItem.uuid) })
}, noteItem => noteItem.uuid)
}
ListItem() { ListItem() {
NoteDataMoveItemComp({ NoteDataMoveItemComp({
folderItem: this.NoteDataMoveArray[this.NoteDataMoveArray.length - 1], folderItem: this.NoteDataMoveArray[this.NoteDataMoveArray.length - 1],
@@ -349,11 +349,19 @@ export struct NoteContentOverViewComp {
getArray() { getArray() {
this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length); 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]); this.NoteDataMoveArray.push(this.AllFolderArray[1]);
} }
aboutToAppear() { aboutToAppear() {
this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length); 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]); this.NoteDataMoveArray.push(this.AllFolderArray[1]);
} }
@@ -369,31 +377,33 @@ export struct NoteContentOverViewComp {
@Builder MenuBuilder() { @Builder MenuBuilder() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
List() { List() {
ForEach(this.NoteDataMoveArray, (item) => { if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null && this.NoteDataMoveArray !== []) {
ListItem() { ForEach(this.NoteDataMoveArray, (item) => {
NoteDataMoveItemCompTablet({ folderItem: item, uuid: this.selectedNoteData.folder_uuid }) 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)
} }
// save continue data .onClick(() => {
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) this.selectedNoteData.folder_uuid = item.uuid
AppStorage.SetOrCreate<string>('ContinueNote', continueNote) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
LogUtil.info(TAG, "NoteContentOverViewComp, MenuBuilder, set continue note success") predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
NoteUtil.refreshAll() RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
}) if (this.sectionStatus != 1) {
}, noteItem => noteItem.uuid) 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) }.listDirection(Axis.Vertical)
.edgeEffect(EdgeEffect.Spring) .edgeEffect(EdgeEffect.Spring)
.height(this.AllFolderArray.length > 12 ? 504 : (this.AllFolderArray.length - 3) * 56) .height(this.AllFolderArray.length > 12 ? 504 : (this.AllFolderArray.length - 3) * 56)
@@ -363,6 +363,10 @@ export struct NoteContentOverViewComp {
aboutToAppear() { aboutToAppear() {
this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length); 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]); this.NoteDataMoveArray.push(this.AllFolderArray[1]);
} }