1/** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import commonEvent from '@ohos.commonEventManager'; 16import router from '@system.router'; 17 18import common from '../../data/commonData'; 19import commonService from '../../service/CommonService'; 20import dateUtil from '../../utils/DateUtil'; 21import LooseObject from '../../data/LooseObject' 22import ConversationListService from '../../service/ConversationListService'; 23import ConversationService from '../../service/ConversationService'; 24import HiLog from '../../utils/HiLog'; 25import NotificationService from '../../service/NotificationService'; 26import settingService from '../../service/SettingService'; 27import ConversationListDataSource from '../../model/ConversationListDataSource' 28 29const TAG = 'InfoMsgController' 30 31let sInfoMsgCtrl; 32 33export default class InfoMsgController { 34 delDialogShow: boolean = false; 35 commonEventData: any = null; 36 svgDelete: string = 'icon/ic_public_delete.svg' 37 total: number = 0; 38 strCheckBoxSelectTip: Resource; 39 strMsgDeleteDialogTip: Resource; 40 // Number of selected sessions 41 conversationSelectedNumber: number = 0; 42 // Indicates whether the multi-select state is selected. 43 isMultipleSelectState: boolean = false; 44 isSearchFocusable: boolean = false; 45 // No The session list is selected. 46 isConversationCheckAll: boolean = false; 47 // Value entered in the search box on the information list page 48 inputValueOfSearch: string = ''; 49 // Indicates whether to lock. The default value is false. No. 50 hasLockMsg: boolean = false; 51 isSelectLockMsg: boolean = false; 52 // List of search results 53 searchResultList: LooseObject = { 54 'sessionList': [], 55 'contentList': [] 56 }; 57 // Search Results Queue 58 searchResultListQueue: Array<any> = []; 59 // Search Text Queue 60 searchTextQueue: Array<any> = []; 61 // Queue timer start flag bit 62 setTimeOutQueueFlag: boolean = false; 63 // Indicates whether to perform redirection to avoid repeated redirection. 64 isJumping: boolean = false; 65 // Indicates whether to display the search return button. By default, the button is not displayed. 66 isShowSearchBack: boolean = false; 67 // The transparent color of the mask is displayed during search. 68 isSearchCoverage: boolean = false; 69 // Display Query All Information 70 isSearchStatus: boolean = true; 71 // Whether to display session search 72 isSearchConversation: boolean = false; 73 // Show Spacer Lines 74 isSearchInterval: boolean = false; 75 // Display Single Information Search 76 isSearchSms: boolean = false; 77 // Display SMS messages when the search result is empty. 78 isSearchNull: boolean = false; 79 // Queue start flag bit 80 queueFlag: boolean = false; 81 // Show Search Status 82 showSearchStatus: string = ''; 83 conversationName: string = ''; 84 // Number of unread notifications. 85 unreadTotalOfInfo: number = 0; 86 messageList: Array<any> = []; 87 // Indicates whether to display the contact profile picture. 88 isShowContactHeadIcon: boolean = true; 89 // Number of search results 90 countOfSearchResult: number = 0; 91 // Display Navigation Bar 92 isNavigationBar: boolean = false; 93 // Search status. Click the search box to enter the search status. 94 searchStatus: boolean = false; 95 // Indicates whether to display the toolbar. The toolbar is not displayed in the search state. 96 showToolBar: boolean = true; 97 // Update the UI. 98 flushTranslate: boolean = true; 99 // Length of the operation button 100 operateBtnW: number = 145; 101 // Data index of the current touch 102 itemTouchedIdx: number = -1; 103 // List pagination, quantity 104 limit: number = 1000; 105 // List pagination, number of pages 106 page: number = 0; 107 // Total number of messages 108 totalMessage: number = 0; 109 // notification conversation list adapters 110 conversationListDataSource: ConversationListDataSource = new ConversationListDataSource(); 111 112 static getInstance() { 113 if (sInfoMsgCtrl == null) { 114 sInfoMsgCtrl = new InfoMsgController(); 115 AppStorage.SetAndLink('InfoMsgController', sInfoMsgCtrl); 116 } 117 return sInfoMsgCtrl; 118 } 119 120 onInit() { 121 HiLog.i(TAG, 'onInit'); 122 this.strCheckBoxSelectTip = $r('app.string.msg_select_all'); 123 this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_tip2', this.conversationSelectedNumber); 124 } 125 126 onShow() { 127 HiLog.i(TAG, 'onShow'); 128 this.isJumping = false; 129 this.getSettingFlagForConvListPage(); 130 this.page = 0; 131 this.requestItem(); 132 this.subscribeInfo(); 133 NotificationService.getInstance().updateBadgeNumber(); 134 } 135 136 onHide() { 137 HiLog.i(TAG, 'onHide'); 138 this.unsubscribeInfo(); 139 } 140 // Querying List Data 141 queryAllMessages() { 142 let actionData: LooseObject = {}; 143 actionData.smsType = common.sms_type.NOTICE; 144 actionData.page = this.page; 145 actionData.limit = this.limit; 146 actionData.orderByTimeDesc = true; 147 ConversationListService.getInstance().querySessionList(actionData, result => { 148 if (result.code == common.int.SUCCESS) { 149 HiLog.i(TAG, 'queryAllMessages, Success'); 150 let res = this.buildSessionList(result); 151 this.messageList = res; 152 this.conversationListDataSource.refresh(this.messageList); 153 this.totalMessage = result.total; 154 this.total = this.messageList.length; 155 if (this.totalMessage === this.total) { 156 this.countUnread(); 157 } 158 } else { 159 HiLog.w(TAG, 'queryAllMessages, failed'); 160 } 161 }, null); 162 } 163 164 dealMmsListContent(element) { 165 if (element.hasMms && element.hasAttachment) { 166 if (element.content == common.string.EMPTY_STR) { 167 element.content = $r('app.string.attachment_no_subject'); 168 } else { 169 element.content = $r('app.string.attachment', element.content); 170 } 171 } 172 if (element.hasMms && !element.hasAttachment && element.content == common.string.EMPTY_STR) { 173 element.content = $r('app.string.no_subject'); 174 } 175 } 176 177 buildSessionList(result) { 178 let res = []; 179 result.response.forEach(item => { 180 // Inherit selected items 181 this.messageList.some(oldItem => { 182 if (item.threadId === oldItem.threadId) { 183 item.isCbChecked = oldItem.isCbChecked; 184 return true; 185 } 186 }); 187 let obj: LooseObject = {}; 188 obj = item; 189 obj.itemLeft = 0; 190 obj.isDelShow = false; 191 dateUtil.convertDateFormatForItem(item, false); 192 this.dealMmsListContent(obj); 193 res.push(obj); 194 }); 195 return res; 196 } 197 198 requestItem() { 199 let count = this.page * this.limit; 200 if (this.page === 0) { 201 this.page++; 202 this.queryAllMessages(); 203 } else if (count < this.totalMessage && this.messageList.length > (this.page - 1) * this.limit) { 204 // The restriction on messageList is to prevent multiple requests from being refreshed during initialization 205 this.page++; 206 this.queryAllMessages(); 207 } 208 } 209 // Return to the information list page. 210 back() { 211 router.back(); 212 } 213 // Tap More at the bottom of the screen 214 clickMore() { 215 // this.$element('moreDialog').show(); 216 } 217 // Delete a single piece of information from a notification. 218 clickToDelete() { 219 220 } 221 222 clickSearchBack() { 223 // Click the search return button. 224 this.backSearch(); 225 } 226 227 backSearch() { 228 this.isShowSearchBack = false; 229 this.isSearchCoverage = false; 230 this.isSearchFocusable = false; 231 this.inputValueOfSearch = common.string.EMPTY_STR; 232 this.isSearchStatus = true; 233 this.isSearchNull = false; 234 this.searchStatus = false; 235 this.showToolBar = true; 236 } 237 238 conversationLongPress(index) { 239 // Check whether the left slide button exists. If yes, the button cannot be clicked. 240 if (this.itemTouchedIdx >= 0 && this.messageList[this.itemTouchedIdx].isDelShow) { 241 return; 242 } 243 // Touch and hold a list to display the selection and deletion functions. 244 this.showToolBar = false; 245 HiLog.i(TAG, 'conversationLongPress, index: ' + index); 246 if (this.isMultipleSelectState) { 247 this.messageList[index].isCbChecked = !this.messageList[index].isCbChecked; 248 } else { 249 this.messageList[index].isCbChecked = true; 250 this.isMultipleSelectState = true; 251 } 252 this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN); 253 } 254 // Check whether all items are selected. 255 setConversationCheckAll(type) { 256 if (!this.isMultipleSelectState) { 257 return; 258 } 259 if (type == common.int.CHECKBOX_SELECT_NONE) { 260 this.conversationSelectedNumber = common.int.MESSAGE_CODE_ZERO; 261 this.isConversationCheckAll = false; 262 } else if (type == common.int.CHECKBOX_SELECT_ALL) { 263 this.conversationSelectedNumber = this.messageList.length; 264 this.isConversationCheckAll = true; 265 } else { 266 // The default value is CHECKBOX_SELECT_UNKNOWN. Check whether there is any unselected item. 267 this.isConversationCheckAll = true; 268 this.conversationSelectedNumber = common.int.MESSAGE_CODE_ZERO; 269 this.messageList.forEach((item, index, array) => { 270 if (item.isCbChecked) { 271 this.conversationSelectedNumber++; 272 } else if (this.isConversationCheckAll) { 273 this.isConversationCheckAll = false; 274 } 275 }); 276 } 277 this.conversationListDataSource.refresh(this.messageList); 278 if (!this.isConversationCheckAll) { 279 // Non-Select All Status 280 this.strCheckBoxSelectTip = $r('app.string.msg_select_all'); 281 } else { 282 // Select All Status 283 this.strCheckBoxSelectTip = $r('app.string.msg_deselect_all'); 284 } 285 } 286 // The SM details page is displayed. 287 clickInfoToConversation(index) { 288 if (this.resetTouch()) { 289 return; 290 } 291 // If multiple options are selected, the system responds to CheckBox. 292 if (this.isMultipleSelectState) { 293 this.messageList[index].isCbChecked = !this.messageList[index].isCbChecked; 294 this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN); 295 return; 296 } 297 if (this.isJumping) { 298 return; 299 } 300 this.isJumping = true; 301 // If the contact has unread information, a message needs to be sent to the backend PA to mark all information 302 // of the contact as read. 303 if (this.messageList[index]?.countOfUnread > common.int.MESSAGE_CODE_ZERO) { 304 this.markAllAsReadByIndex(index); 305 } 306 this.jumpToConversationPage(this.messageList[index]); 307 } 308 // The session details page is displayed. 309 jumpToConversationPage(item) { 310 router.push({ 311 uri: 'pages/conversation/conversation', 312 params: { 313 strContactsNumber: item?.telephone, 314 strContactsNumberFormat: item?.telephoneFormat, 315 strContactsName: item?.name, 316 contactsNum: item?.contactsNum, 317 threadId: item?.threadId, 318 isDraft: item?.isDraft, 319 draftContent: item?.content, 320 searchContent: this.inputValueOfSearch 321 } 322 }); 323 } 324 // Searching for a session avatar 325 searchConversationHeadClick(index) { 326 this.headClickedListener(this.searchResultList.sessionList[index]); 327 } 328 329 headClickedListener(item) { 330 // Tap the avatar to go to the contact details page or recipient list page. 331 if (this.isJumping) { 332 return; 333 } 334 if (item.isFavorite != null && item.isFavorite) { 335 return; 336 } 337 var telephone = item.telephone; 338 var contactsNum = item.contactsNum; 339 this.isJumping = true; 340 if (contactsNum == common.int.MESSAGE_CODE_ONE) { 341 var actionData: LooseObject = {}; 342 actionData.phoneNumber = telephone; 343 actionData.pageFlag = common.contactPage.PAGE_FLAG_CONTACT_DETAILS; 344 this.jumpToContact(actionData); 345 } else { 346 let threadId = item.threadId; 347 let contactsNum = item.contactsNum; 348 this.jumpToGroupDetail(threadId, contactsNum); 349 } 350 } 351 // Go to the multi-faceted portrait list page. 352 jumpToGroupDetail(threadId, contactsNum) { 353 let actionData = { 354 uri: 'pages/group_detail/group_detail', 355 params: { 356 threadId: threadId, 357 contactsNum: contactsNum 358 } 359 }; 360 this.isJumping = false; 361 router.push(actionData); 362 } 363 // Go to session details. 364 searchConversationClick(index) { 365 this.searchMmsClicked(this.searchResultList.sessionList[index]); 366 } 367 // Go to SMS details. 368 searchMmsClicked(item) { 369 if (item.isFavorite) { 370 router.push({ 371 uri: 'pages/my_star/my_star', 372 params: { 373 searchContent: this.inputValueOfSearch 374 } 375 }); 376 } else { 377 this.jumpToConversationPage(item); 378 } 379 } 380 // Clicking a profile picture to jump to the contact details page or the list page of multiple recipients 381 searchSmsHeadClick(index) { 382 this.headClickedListener(this.searchResultList.contentList[index]); 383 } 384 // The session details page is displayed. 385 searchSmsClick(index) { 386 this.searchMmsClicked(this.searchResultList.contentList[index]); 387 } 388 // Slide your finger to exit the search mode. 389 searchCoverageClick() { 390 this.backSearch(); 391 } 392 // Counting the number of unread messages 393 countUnread() { 394 let that = this; 395 ConversationListService.getInstance().statisticalData(result => { 396 if (result.code == common.int.SUCCESS) { 397 // Unreading of notification messages 398 that.unreadTotalOfInfo = result.response.unreadTotalOfInfo; 399 HiLog.i(TAG, 'countUnread = ' + that.unreadTotalOfInfo); 400 NotificationService.getInstance().setBadgeNumber(Number(result.response.totalListCount)); 401 } else { 402 HiLog.w(TAG, 'countUnread, statisticalData failed'); 403 } 404 }, null); 405 } 406 // Mark all unread notifications as read. 407 clickToMarkAllAsReadForInfo() { 408 let threadIds: Array<number> = []; 409 for (let msg of this.messageList) { 410 msg.countOfUnread = common.int.MESSAGE_CODE_ZERO; 411 threadIds.push(msg.threadId); 412 } 413 let actionData: LooseObject = {}; 414 actionData.threadIds = threadIds; 415 actionData.hasRead = common.is_read.UN_READ; 416 actionData.smsType = common.sms_type.NOTICE; 417 NotificationService.getInstance().cancelMessageNotify(actionData); 418 ConversationListService.getInstance().markAllToRead(actionData); 419 NotificationService.getInstance().updateBadgeNumber(); 420 this.unreadTotalOfInfo = 0; 421 } 422 423 markAllAsReadByIndex(index) { 424 let item: LooseObject = this.messageList[index]; 425 let threadId: number = item.threadId; 426 let actionData: LooseObject = {}; 427 actionData.threadId = threadId; 428 actionData.hasRead = common.is_read.UN_READ; 429 NotificationService.getInstance().cancelMessageNotify(actionData); 430 NotificationService.getInstance().updateBadgeNumber(); 431 ConversationListService.getInstance().markAllToRead(actionData); 432 let tempMsgList: Array<LooseObject> = this.messageList; 433 for (let msg of tempMsgList) { 434 if (threadId == msg.threadId) { 435 // Controls the display of unread icons in the list 436 msg.countOfUnread = common.int.MESSAGE_CODE_ZERO; 437 } 438 } 439 this.messageList = tempMsgList; 440 this.conversationListDataSource.refresh(this.messageList); 441 this.unreadTotalOfInfo = this.unreadTotalOfInfo - 1; 442 443 this.setListItemTransX(0); 444 item.isDelShow = false; 445 } 446 447 selectInMoreMenu(menuId: number) { 448 if (menuId == 1) { 449 // Delete 450 this.isMultipleSelectState = true; 451 this.showToolBar = false; 452 this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN); 453 } else { 454 // The harassment blocking page is displayed, which is in the Phone Manager app. 455 } 456 } 457 // Button Delete 458 clickConversationDelete() { 459 if (this.conversationSelectedNumber == common.int.MESSAGE_CODE_ZERO) { 460 return; 461 } 462 if (this.conversationSelectedNumber == common.int.MESSAGE_CODE_ONE) { 463 this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_tip1'); 464 } else if (this.conversationSelectedNumber == this.messageList.length) { 465 this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_tip3'); 466 } else { 467 this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_tip2', this.conversationSelectedNumber); 468 } 469 this.hasLockMsg = (this.messageList.some((element, index) => element.isCbChecked && element.isLock)); 470 } 471 472 checkSelectedNumberIsEmpty() { 473 return this.conversationSelectedNumber == common.int.MESSAGE_CODE_ZERO 474 } 475 // Cancel Ejection 476 deleteDialogCancel() { 477 if (this.isSelectLockMsg) { 478 this.isSelectLockMsg = false; 479 } 480 } 481 482 setSelectLock() { 483 this.isSelectLockMsg = !this.isSelectLockMsg; 484 } 485 // Delete the checkbox lockout event. 486 setSelectLockChange(event) { 487 this.isSelectLockMsg = event.checked; 488 } 489 490 deleteDialogConfirm() { 491 this.setDelShow(); 492 let mmsList: Array<LooseObject> = []; 493 let threadIds: Array<number> = []; 494 for (let element of this.messageList) { 495 if (element.isCbChecked) { 496 threadIds.push(element.threadId); 497 } else { 498 mmsList.push(element); 499 } 500 } 501 this.isMultipleSelectState = false; 502 this.showToolBar = true; 503 this.isSelectLockMsg = false; 504 this.messageList = mmsList; 505 this.conversationListDataSource.refresh(this.messageList); 506 this.total = mmsList.length; 507 if (this.total == 0) { 508 router.back(); 509 } 510 let actionData: LooseObject = {}; 511 actionData.threadIds = threadIds; 512 actionData.hasRead = common.is_read.UN_READ; 513 NotificationService.getInstance().cancelMessageNotify(actionData); 514 NotificationService.getInstance().updateBadgeNumber(); 515 actionData.hasRead = null; 516 ConversationListService.getInstance().deleteMessageById(actionData, null, null); 517 } 518 519 setDelShow() { 520 if (this.itemTouchedIdx >= 0) { 521 let item = this.messageList[this.itemTouchedIdx]; 522 this.setListItemTransX(0); 523 item.isDelShow = false; 524 } 525 }; 526 527 // Select All/Deselect All 528 clickConversationCheckAll() { 529 if (this.isConversationCheckAll) { 530 // Select All --> Deselect All 531 for (let item of this.messageList) { 532 item.isCbChecked = false; 533 } 534 this.setConversationCheckAll(common.int.CHECKBOX_SELECT_NONE); 535 } else { 536 // Not Select All --> Select All 537 for (let item of this.messageList) { 538 item.isCbChecked = true; 539 } 540 this.setConversationCheckAll(common.int.CHECKBOX_SELECT_ALL); 541 } 542 } 543 544 onBackPress() { 545 // Key returned by the system. The value true indicates interception. 546 if (this.isMultipleSelectState) { 547 for (let element of this.messageList) { 548 element.isCbChecked = false; 549 } 550 this.isMultipleSelectState = false; 551 this.showToolBar = true; 552 return true; 553 } 554 return false; 555 } 556 // Tap the avatar to go to the contact details page or recipient list page. 557 clickToGroupDetail(index) { 558 if (this.isJumping) { 559 return; 560 } 561 this.isJumping = true; 562 // Determine whether to redirect to the contact details page or to the list page of multiple recipients. 563 var contactsNum = this.messageList[index]?.contactsNum; 564 var telephone = this.messageList[index]?.telephone; 565 if (contactsNum == common.int.MESSAGE_CODE_ONE) { 566 var actionData = { 567 phoneNumber: telephone, 568 pageFlag: common.contactPage.PAGE_FLAG_CONTACT_DETAILS 569 }; 570 this.jumpToContact(actionData); 571 } else { 572 let threadId = this.messageList[index]?.threadId; 573 let contactsNum = this.messageList[index]?.contactsNum; 574 this.jumpToGroupDetail(threadId, contactsNum); 575 } 576 } 577 578 exitConversationSelect() { 579 this.onBackPress(); 580 } 581 582 touchStart(event: GestureEvent, index: number) { 583 if (this.isMultipleSelectState) { 584 return; 585 } 586 // Check whether the current touch item is the same as that of a touch item. 587 // If not, reset the previous touch item. 588 if (this.itemTouchedIdx !== -1 && index !== this.itemTouchedIdx) { 589 let itemTouched = this.messageList[this.itemTouchedIdx]; 590 if (itemTouched != undefined && itemTouched != null && itemTouched.isDelShow) { 591 this.setListItemTransX(0); 592 itemTouched.isDelShow = false; 593 } 594 } 595 this.itemTouchedIdx = index; 596 let item = this.messageList[this.itemTouchedIdx]; 597 if (item == null || item == undefined) { 598 return; 599 } 600 if (item.countOfUnread > 0) { 601 this.operateBtnW = common.int.OPERATE_UNREAD_WIDTH; 602 } else { 603 this.operateBtnW = common.int.OPERATE_DELETE_WIDTH; 604 } 605 } 606 607 resetTouch() { 608 if (this.itemTouchedIdx !== -1) { 609 let item = this.messageList[this.itemTouchedIdx]; 610 if (item == undefined) { 611 return false; 612 } 613 if (item.isDelShow) { 614 item.isDelShow = false; 615 this.setListItemTransX(0); 616 return true; 617 } 618 } 619 return false; 620 } 621 622 touchMove(event: GestureEvent, index: number) { 623 if (this.isMultipleSelectState) { 624 return; 625 } 626 // offsetX indicates the offset. The value range is [-operateBtnW, 0]. 627 let offsetX = event.offsetX; 628 // If the displacement is less than 2, there is no sliding. 629 if (Math.abs(offsetX) <= 2) { 630 return; 631 } 632 let item = this.messageList[this.itemTouchedIdx]; 633 let transX = offsetX; 634 if (item.isDelShow) { 635 if (event.offsetX - this.operateBtnW <= 0) { 636 transX = event.offsetX - this.operateBtnW 637 } else { 638 // Slide right to close 639 transX = 0 640 } 641 } else { 642 if (event.offsetX + this.operateBtnW >= 0) { 643 transX = event.offsetX 644 } else { 645 // Slide left to maximum width 646 transX = 0 - this.operateBtnW; 647 } 648 } 649 this.setListItemTransX(transX); 650 } 651 652 deleteAction(idx) { 653 let element = this.messageList[idx]; 654 this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_tip1'); 655 element.isCbChecked = true; 656 this.hasLockMsg = (this.messageList.some((element, index) => element.isCbChecked && element.isLock)); 657 } 658 659 touchEnd(event: GestureEvent, index: number) { 660 if (this.isMultipleSelectState) { 661 return; 662 } 663 // offsetX indicates the offset. The value range is [-operateBtnW, 0]. 664 let offsetX = event.offsetX; 665 let item = this.messageList[this.itemTouchedIdx]; 666 if (offsetX + (this.operateBtnW / 2) >= 0) { 667 this.setListItemTransX(0); 668 item.isDelShow = false; 669 } else { 670 this.setListItemTransX(0 - this.operateBtnW); 671 item.isDelShow = true; 672 } 673 } 674 // Subscribe to New Messages Received 675 subscribeInfo() { 676 HiLog.i(TAG, 'subscribeInfo, start'); 677 let events = [common.string.RECEIVE_TRANSMIT_EVENT] 678 let commonEventSubscribeInfo = { 679 events: events 680 }; 681 commonEvent.createSubscriber(commonEventSubscribeInfo, this.createSubscriberCallBack.bind(this)); 682 } 683 684 setListItemTransX(transX) { 685 let item = this.messageList[this.itemTouchedIdx]; 686 if (item) { 687 if (transX <= 0) { 688 item.itemLeft = transX; 689 } else { 690 item.itemLeft = 0; 691 } 692 } 693 // Used to refresh the interface. 694 this.flushTranslate = !this.flushTranslate; 695 } 696 697 createSubscriberCallBack(err, data) { 698 this.commonEventData = data; 699 // Received subscription 700 commonEvent.subscribe(this.commonEventData, this.subscriberCallBack.bind(this)); 701 } 702 703 subscriberCallBack(err, data) { 704 this.page = 1; 705 this.queryAllMessages(); 706 } 707 // Unsubscribe 708 unsubscribeInfo() { 709 if (this.commonEventData != null) { 710 commonEvent.unsubscribe(this.commonEventData, () => { 711 HiLog.i(TAG, 'unsubscribeInfo, success'); 712 }); 713 } 714 } 715 // Switching to the Contacts app 716 jumpToContact(actionData) { 717 var str = commonService.commonContactParam(actionData); 718 globalThis.mmsContext.startAbility(str).then((data) => { 719 }).catch((error) => { 720 HiLog.e(TAG, 'jumpToContact, failed: ' + JSON.stringify(error.message)); 721 }) 722 this.isJumping = false; 723 } 724 // Obtains the switch value for integrating notification information and displaying contact avatars. 725 getSettingFlagForConvListPage() { 726 let result = settingService.getSettingFlagForConvListPage(); 727 if (result) { 728 this.isShowContactHeadIcon = result.isShowContactHeadIcon; 729 } 730 } 731} 732