Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool into main
* 'main' of http://192.168.1.42/developOne/harmonyPool: ref |> 对接直播置顶,取消置顶,上墙IM消息
Showing
3 changed files
with
60 additions
and
16 deletions
| @@ -102,7 +102,8 @@ export function LiveMessageIsHistoryMessage(optionType: LiveMessageOptType): boo | @@ -102,7 +102,8 @@ export function LiveMessageIsHistoryMessage(optionType: LiveMessageOptType): boo | ||
| 102 | case LiveMessageOptType.ZH_IMAGE_MSG: | 102 | case LiveMessageOptType.ZH_IMAGE_MSG: |
| 103 | case LiveMessageOptType.ZH_TEXT_AND_IMAGE_MSG: | 103 | case LiveMessageOptType.ZH_TEXT_AND_IMAGE_MSG: |
| 104 | case LiveMessageOptType.ZH_AUDIO_MSG: | 104 | case LiveMessageOptType.ZH_AUDIO_MSG: |
| 105 | - case LiveMessageOptType.ZH_VIDEO_MSG: { | 105 | + case LiveMessageOptType.ZH_VIDEO_MSG: |
| 106 | + case LiveMessageOptType.ZH_WALL_MSG: { | ||
| 106 | isHistoryMessage = true | 107 | isHistoryMessage = true |
| 107 | } break; | 108 | } break; |
| 108 | default: | 109 | default: |
| @@ -7,13 +7,14 @@ import { | @@ -7,13 +7,14 @@ import { | ||
| 7 | LiveRoomItemBean, | 7 | LiveRoomItemBean, |
| 8 | ValueType | 8 | ValueType |
| 9 | } from 'wdBean/Index' | 9 | } from 'wdBean/Index' |
| 10 | -import { LiveMessageIsHistoryMessage } from 'wdBean/src/main/ets/bean/live/LiveRoomBean' | 10 | +import { LiveMessageIsHistoryMessage, LiveMessageOptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean' |
| 11 | import { SpConstants } from 'wdConstant' | 11 | import { SpConstants } from 'wdConstant' |
| 12 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' | 12 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' |
| 13 | -import { LazyDataSource, Logger, SPHelper } from 'wdKit/Index' | 13 | +import { DateTimeUtils, LazyDataSource, Logger, SPHelper } from 'wdKit/Index' |
| 14 | import { ToastUtils } from 'wdKit/src/main/ets/utils/ToastUtils' | 14 | import { ToastUtils } from 'wdKit/src/main/ets/utils/ToastUtils' |
| 15 | import { HttpUtils, ResponseDTO } from 'wdNetwork/Index' | 15 | import { HttpUtils, ResponseDTO } from 'wdNetwork/Index' |
| 16 | import { LiveModel } from './LiveModel' | 16 | import { LiveModel } from './LiveModel' |
| 17 | +import { ArrayList } from '@kit.ArkTS' | ||
| 17 | 18 | ||
| 18 | const TAG = "LiveViewModel" | 19 | const TAG = "LiveViewModel" |
| 19 | 20 | ||
| @@ -242,4 +243,42 @@ export class LiveViewModel { | @@ -242,4 +243,42 @@ export class LiveViewModel { | ||
| 242 | } | 243 | } |
| 243 | return index | 244 | return index |
| 244 | } | 245 | } |
| 246 | + ///处理置顶/取消置顶消息 | ||
| 247 | + sortLiveRoomItemBean(liveRoomItemBean:LiveRoomItemBean, dataSource:LazyDataSource<LiveRoomItemBean>):LazyDataSource<LiveRoomItemBean> { | ||
| 248 | + if (liveRoomItemBean.optionType == LiveMessageOptType.ZH_TOP_MSG || liveRoomItemBean.optionType == LiveMessageOptType.ZH_UN_TOP_MSG) { | ||
| 249 | + const index = this.getLiveRoomItemBeanIndex(liveRoomItemBean, dataSource); | ||
| 250 | + const currentLiveRoomItemBean = dataSource.get(index) | ||
| 251 | + currentLiveRoomItemBean.isTop = liveRoomItemBean.isTop | ||
| 252 | + dataSource.deleteItem(index) | ||
| 253 | + dataSource.addFirstItem(currentLiveRoomItemBean) | ||
| 254 | + }else { | ||
| 255 | + if (LiveMessageIsHistoryMessage(liveRoomItemBean.optionType != undefined ? liveRoomItemBean.optionType : | ||
| 256 | + liveRoomItemBean.dataType)) { | ||
| 257 | + dataSource.addItem(liveRoomItemBean) | ||
| 258 | + } | ||
| 259 | + } | ||
| 260 | + let resultMessageList: LazyDataSource<LiveRoomItemBean> = new LazyDataSource() | ||
| 261 | + let topMessageList: LazyDataSource<LiveRoomItemBean> = new LazyDataSource() | ||
| 262 | + let unTopMessageList: LazyDataSource<LiveRoomItemBean> = new LazyDataSource() | ||
| 263 | + for (let itemBean of dataSource.getDataArray()) { | ||
| 264 | + if (itemBean.isTop == 1) { | ||
| 265 | + topMessageList.push(itemBean) | ||
| 266 | + } else { | ||
| 267 | + unTopMessageList.push(itemBean) | ||
| 268 | + } | ||
| 269 | + } | ||
| 270 | + topMessageList.sort((item: LiveRoomItemBean, item2: LiveRoomItemBean) => { | ||
| 271 | + let timeStamp1 = DateTimeUtils.parseDate(item.time, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN) | ||
| 272 | + let timeStamp2 = DateTimeUtils.parseDate(item2.time, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN) | ||
| 273 | + return timeStamp2 - timeStamp1 | ||
| 274 | + }) | ||
| 275 | + unTopMessageList.sort((item: LiveRoomItemBean, item2: LiveRoomItemBean) => { | ||
| 276 | + let timeStamp1 = DateTimeUtils.parseDate(item.time, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN) | ||
| 277 | + let timeStamp2 = DateTimeUtils.parseDate(item2.time, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN) | ||
| 278 | + return timeStamp2 - timeStamp1 | ||
| 279 | + }) | ||
| 280 | + resultMessageList.addItems(topMessageList.getDataArray()) | ||
| 281 | + resultMessageList.addItems(unTopMessageList.getDataArray()) | ||
| 282 | + return resultMessageList | ||
| 283 | + } | ||
| 245 | } | 284 | } |
| @@ -11,6 +11,7 @@ import { Logger } from 'wdKit' | @@ -11,6 +11,7 @@ import { Logger } from 'wdKit' | ||
| 11 | import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout' | 11 | import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout' |
| 12 | import { PeopleShipNoMoreData } from 'wdComponent/src/main/ets/components/reusable/PeopleShipNoMoreData' | 12 | import { PeopleShipNoMoreData } from 'wdComponent/src/main/ets/components/reusable/PeopleShipNoMoreData' |
| 13 | import { LiveMessageOptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean' | 13 | import { LiveMessageOptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean' |
| 14 | +import { ArrayList } from '@kit.ArkTS' | ||
| 14 | 15 | ||
| 15 | const TAG: string = 'TabLiveComponent'; | 16 | const TAG: string = 'TabLiveComponent'; |
| 16 | 17 | ||
| @@ -37,25 +38,28 @@ export struct TabLiveComponent { | @@ -37,25 +38,28 @@ export struct TabLiveComponent { | ||
| 37 | Logger.debug(TAG, "1显示评论》》》: " + JSON.stringify(this.lastInputedComment)) | 38 | Logger.debug(TAG, "1显示评论》》》: " + JSON.stringify(this.lastInputedComment)) |
| 38 | switch (this.lastInputedComment.optionType) { | 39 | switch (this.lastInputedComment.optionType) { |
| 39 | case LiveMessageOptType.ZH_UPDATE_MSG: { | 40 | case LiveMessageOptType.ZH_UPDATE_MSG: { |
| 40 | - const index = this.liveViewModel.getLiveRoomItemBeanIndex(this.lastInputedComment,this.liveList) | ||
| 41 | - this.liveList.updateItem(this.lastInputedComment,index) | 41 | + const index = this.liveViewModel.getLiveRoomItemBeanIndex(this.lastInputedComment, this.liveList) |
| 42 | + this.liveList.updateItem(this.lastInputedComment, index) | ||
| 42 | return | 43 | return |
| 43 | - } break | 44 | + } |
| 45 | + break | ||
| 44 | case LiveMessageOptType.ZH_DELETE_MSG: { | 46 | case LiveMessageOptType.ZH_DELETE_MSG: { |
| 45 | - const index = this.liveViewModel.getLiveRoomItemBeanIndex(this.lastInputedComment,this.liveList) | 47 | + const index = this.liveViewModel.getLiveRoomItemBeanIndex(this.lastInputedComment, this.liveList) |
| 46 | this.liveList.deleteItem(index); | 48 | this.liveList.deleteItem(index); |
| 47 | return | 49 | return |
| 48 | } | 50 | } |
| 49 | break | 51 | break |
| 50 | - case LiveMessageOptType.ZH_TOP_MSG: { | ||
| 51 | - | ||
| 52 | - } break | ||
| 53 | - case LiveMessageOptType.ZH_UN_TOP_MSG: { | ||
| 54 | - | ||
| 55 | - } break | ||
| 56 | - case LiveMessageOptType.ZH_WALL_MSG: { | ||
| 57 | - | ||
| 58 | - } break | 52 | + case LiveMessageOptType.ZH_TOP_MSG: |
| 53 | + case LiveMessageOptType.ZH_UN_TOP_MSG: | ||
| 54 | + case LiveMessageOptType.ZH_WALL_MSG: | ||
| 55 | + default: { | ||
| 56 | + let datas: LazyDataSource<LiveRoomItemBean> = | ||
| 57 | + this.liveViewModel.sortLiveRoomItemBean(this.lastInputedComment, this.liveList) | ||
| 58 | + this.liveList.replaceAll() | ||
| 59 | + this.liveList.addItems(datas.getDataArray()) | ||
| 60 | + return | ||
| 61 | + } | ||
| 62 | + break | ||
| 59 | } | 63 | } |
| 60 | 64 | ||
| 61 | if (this.liveList.totalCount() === 0) { | 65 | if (this.liveList.totalCount() === 0) { |
-
Please register or login to post a comment