Refactor cell view model

This commit is contained in:
ismailgulek
2020-09-10 16:41:34 +03:00
parent 6afc2df1fb
commit 78152a8b04
2 changed files with 34 additions and 25 deletions
@@ -43,7 +43,15 @@ final class ShowDirectoryViewModel: NSObject, ShowDirectoryViewModelType {
}
func roomViewModel(at indexPath: IndexPath) -> DirectoryRoomTableViewCellVM? {
guard let room = dataSource.room(at: indexPath) else { return nil }
return DirectoryRoomTableViewCellVM(room: room, session: session)
let summary = session.roomSummary(withRoomId: room.roomId)
return DirectoryRoomTableViewCellVM(title: room.displayname(),
numberOfUsers: room.numJoinedMembers,
subtitle: MXTools.stripNewlineCharacters(room.topic),
isJoined: summary?.membership == .join,
roomId: room.roomId,
avatarUrl: room.avatarUrl,
mediaManager: session.mediaManager)
}
// MARK: - Setup