Commit 07c5c0bf authored by Lucio Maciel's avatar Lucio Maciel

Clean up unused code

parent 25f39958
...@@ -326,7 +326,7 @@ class LoginPresenter @Inject constructor( ...@@ -326,7 +326,7 @@ class LoginPresenter @Inject constructor(
getCustomOauthScope(serviceMap) ?: "openid" getCustomOauthScope(serviceMap) ?: "openid"
) )
} }
wordpressOauthUrl?.let { wordpressOauthUrl.let {
view.setupWordpressButtonListener(it, state) view.setupWordpressButtonListener(it, state)
view.enableLoginByWordpress() view.enableLoginByWordpress()
totalSocialAccountsEnabled++ totalSocialAccountsEnabled++
......
...@@ -51,7 +51,7 @@ class ActionsListAdapter(actions: List<Action>, var actionAttachmentOnClickListe ...@@ -51,7 +51,7 @@ class ActionsListAdapter(actions: List<Action>, var actionAttachmentOnClickListe
action_button.isVisible = true action_button.isVisible = true
action_image_button.isVisible = false action_image_button.isVisible = false
this.action_button.setText(action.text) this.action_button.text = action.text
} }
} }
} }
......
...@@ -28,7 +28,6 @@ import chat.rocket.android.server.domain.JobSchedulerInteractor ...@@ -28,7 +28,6 @@ import chat.rocket.android.server.domain.JobSchedulerInteractor
import chat.rocket.android.server.domain.MessagesRepository import chat.rocket.android.server.domain.MessagesRepository
import chat.rocket.android.server.domain.PermissionsInteractor import chat.rocket.android.server.domain.PermissionsInteractor
import chat.rocket.android.server.domain.PublicSettings import chat.rocket.android.server.domain.PublicSettings
import chat.rocket.android.server.domain.RoomRepository
import chat.rocket.android.server.domain.UsersRepository import chat.rocket.android.server.domain.UsersRepository
import chat.rocket.android.server.domain.uploadMaxFileSize import chat.rocket.android.server.domain.uploadMaxFileSize
import chat.rocket.android.server.domain.uploadMimeTypeFilter import chat.rocket.android.server.domain.uploadMimeTypeFilter
...@@ -92,7 +91,6 @@ class ChatRoomPresenter @Inject constructor( ...@@ -92,7 +91,6 @@ class ChatRoomPresenter @Inject constructor(
private val uriInteractor: UriInteractor, private val uriInteractor: UriInteractor,
private val messagesRepository: MessagesRepository, private val messagesRepository: MessagesRepository,
private val usersRepository: UsersRepository, private val usersRepository: UsersRepository,
private val roomsRepository: RoomRepository,
private val localRepository: LocalRepository, private val localRepository: LocalRepository,
private val analyticsManager: AnalyticsManager, private val analyticsManager: AnalyticsManager,
private val userHelper: UserHelper, private val userHelper: UserHelper,
...@@ -505,7 +503,7 @@ class ChatRoomPresenter @Inject constructor( ...@@ -505,7 +503,7 @@ class ChatRoomPresenter @Inject constructor(
val messages = val messages =
retryIO(description = "history($chatRoomId, $roomType, $instant)") { retryIO(description = "history($chatRoomId, $roomType, $instant)") {
client.history( client.history(
chatRoomId!!, roomType, count = 50, chatRoomId, roomType, count = 50,
oldest = instant oldest = instant
) )
} }
...@@ -714,6 +712,7 @@ class ChatRoomPresenter @Inject constructor( ...@@ -714,6 +712,7 @@ class ChatRoomPresenter @Inject constructor(
client.getMembers(chatRoomId, roomTypeOf(chatRoomType), offset, 50).result client.getMembers(chatRoomId, roomTypeOf(chatRoomType), offset, 50).result
}.take(50) // Get only 50, the backend is returning 7k+ users }.take(50) // Get only 50, the backend is returning 7k+ users
usersRepository.saveAll(members) usersRepository.saveAll(members)
dbManager.processUsersBatch(members)
val self = localRepository.get(LocalRepository.CURRENT_USERNAME_KEY) val self = localRepository.get(LocalRepository.CURRENT_USERNAME_KEY)
// Take at most the 100 most recent messages distinguished by user. Can return less. // Take at most the 100 most recent messages distinguished by user. Can return less.
val recentMessages = messagesRepository.getRecentMessages(chatRoomId, 100) val recentMessages = messagesRepository.getRecentMessages(chatRoomId, 100)
...@@ -786,9 +785,6 @@ class ChatRoomPresenter @Inject constructor( ...@@ -786,9 +785,6 @@ class ChatRoomPresenter @Inject constructor(
}.filterNot { filterSelfOut && self != null && self == it.text }) }.filterNot { filterSelfOut && self != null && self == it.text })
} }
ROOMS -> { ROOMS -> {
if (rooms.isNotEmpty()) {
roomsRepository.saveAll(rooms)
}
view.populateRoomSuggestions(rooms.map { view.populateRoomSuggestions(rooms.map {
val fullName = it.fullName ?: "" val fullName = it.fullName ?: ""
val name = it.name ?: "" val name = it.name ?: ""
......
...@@ -175,7 +175,7 @@ class UiModelMapper @Inject constructor( ...@@ -175,7 +175,7 @@ class UiModelMapper @Inject constructor(
broadcast = broadcast ?: false, broadcast = broadcast ?: false,
alert = alert, alert = alert,
fullName = fullname, fullName = fullname,
name = name ?: "", name = name,
favorite = favorite ?: false, favorite = favorite ?: false,
default = isDefault ?: false, default = isDefault ?: false,
readonly = readonly, readonly = readonly,
...@@ -477,7 +477,7 @@ class UiModelMapper @Inject constructor( ...@@ -477,7 +477,7 @@ class UiModelMapper @Inject constructor(
val time = getTime(message.timestamp) val time = getTime(message.timestamp)
val avatar = getUserAvatar(message) val avatar = getUserAvatar(message)
val preview = mapMessagePreview(message) val preview = mapMessagePreview(message)
val synced = message.synced ?: true val synced = message.synced
val unread = if (settings.messageReadReceiptEnabled()) { val unread = if (settings.messageReadReceiptEnabled()) {
message.unread ?: false message.unread ?: false
} else { } else {
......
...@@ -5,5 +5,4 @@ import chat.rocket.android.suggestions.model.SuggestionModel ...@@ -5,5 +5,4 @@ import chat.rocket.android.suggestions.model.SuggestionModel
class ChatRoomSuggestionUiModel(text: String, class ChatRoomSuggestionUiModel(text: String,
val fullName: String, val fullName: String,
val name: String, val name: String,
searchList: List<String>) : SuggestionModel(text, searchList, false) { searchList: List<String>) : SuggestionModel(text, searchList, false)
} \ No newline at end of file
\ No newline at end of file
...@@ -9,7 +9,6 @@ import android.content.Context ...@@ -9,7 +9,6 @@ import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import chat.rocket.android.BuildConfig import chat.rocket.android.BuildConfig
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.analytics.Analytics
import chat.rocket.android.analytics.AnalyticsManager import chat.rocket.android.analytics.AnalyticsManager
import chat.rocket.android.analytics.AnswersAnalytics import chat.rocket.android.analytics.AnswersAnalytics
import chat.rocket.android.analytics.GoogleAnalyticsForFirebase import chat.rocket.android.analytics.GoogleAnalyticsForFirebase
...@@ -26,7 +25,6 @@ import chat.rocket.android.infrastructure.SharedPreferencesLocalRepository ...@@ -26,7 +25,6 @@ import chat.rocket.android.infrastructure.SharedPreferencesLocalRepository
import chat.rocket.android.push.GroupedPush import chat.rocket.android.push.GroupedPush
import chat.rocket.android.push.PushManager import chat.rocket.android.push.PushManager
import chat.rocket.android.server.domain.AccountsRepository import chat.rocket.android.server.domain.AccountsRepository
import chat.rocket.android.server.domain.ActiveUsersRepository
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.server.domain.AnalyticsTrackingRepository import chat.rocket.android.server.domain.AnalyticsTrackingRepository
import chat.rocket.android.server.domain.ChatRoomsRepository import chat.rocket.android.server.domain.ChatRoomsRepository
...@@ -39,16 +37,13 @@ import chat.rocket.android.server.domain.JobSchedulerInteractor ...@@ -39,16 +37,13 @@ import chat.rocket.android.server.domain.JobSchedulerInteractor
import chat.rocket.android.server.domain.MessagesRepository import chat.rocket.android.server.domain.MessagesRepository
import chat.rocket.android.server.domain.MultiServerTokenRepository import chat.rocket.android.server.domain.MultiServerTokenRepository
import chat.rocket.android.server.domain.PermissionsRepository import chat.rocket.android.server.domain.PermissionsRepository
import chat.rocket.android.server.domain.RoomRepository
import chat.rocket.android.server.domain.SettingsRepository import chat.rocket.android.server.domain.SettingsRepository
import chat.rocket.android.server.domain.TokenRepository import chat.rocket.android.server.domain.TokenRepository
import chat.rocket.android.server.domain.UsersRepository import chat.rocket.android.server.domain.UsersRepository
import chat.rocket.android.server.infraestructure.DatabaseMessageMapper import chat.rocket.android.server.infraestructure.DatabaseMessageMapper
import chat.rocket.android.server.infraestructure.DatabaseMessagesRepository import chat.rocket.android.server.infraestructure.DatabaseMessagesRepository
import chat.rocket.android.server.infraestructure.JobSchedulerInteractorImpl import chat.rocket.android.server.infraestructure.JobSchedulerInteractorImpl
import chat.rocket.android.server.infraestructure.MemoryActiveUsersRepository
import chat.rocket.android.server.infraestructure.MemoryChatRoomsRepository import chat.rocket.android.server.infraestructure.MemoryChatRoomsRepository
import chat.rocket.android.server.infraestructure.MemoryRoomRepository
import chat.rocket.android.server.infraestructure.MemoryUsersRepository import chat.rocket.android.server.infraestructure.MemoryUsersRepository
import chat.rocket.android.server.infraestructure.SharedPreferencesAccountsRepository import chat.rocket.android.server.infraestructure.SharedPreferencesAccountsRepository
import chat.rocket.android.server.infraestructure.SharedPreferencesPermissionsRepository import chat.rocket.android.server.infraestructure.SharedPreferencesPermissionsRepository
...@@ -202,24 +197,12 @@ class AppModule { ...@@ -202,24 +197,12 @@ class AppModule {
return SharedPreferencesPermissionsRepository(localRepository, moshi) return SharedPreferencesPermissionsRepository(localRepository, moshi)
} }
@Provides
@Singleton
fun provideRoomRepository(): RoomRepository {
return MemoryRoomRepository()
}
@Provides @Provides
@Singleton @Singleton
fun provideChatRoomRepository(): ChatRoomsRepository { fun provideChatRoomRepository(): ChatRoomsRepository {
return MemoryChatRoomsRepository() return MemoryChatRoomsRepository()
} }
@Provides
@Singleton
fun provideActiveUsersRepository(): ActiveUsersRepository {
return MemoryActiveUsersRepository()
}
@Provides @Provides
@Singleton @Singleton
fun provideMoshi( fun provideMoshi(
......
...@@ -4,7 +4,7 @@ import androidx.room.Insert ...@@ -4,7 +4,7 @@ import androidx.room.Insert
import androidx.room.OnConflictStrategy import androidx.room.OnConflictStrategy
interface BaseDao<T> { interface BaseDao<T> {
@Insert @Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg obj: T) fun insert(vararg obj: T)
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
......
package chat.rocket.android.server.domain
import chat.rocket.common.model.User
interface ActiveUsersRepository {
fun save(url: String, activeUsers: List<User>)
fun get(url: String): List<User>
}
\ No newline at end of file
package chat.rocket.android.server.domain
import chat.rocket.common.model.User
import javax.inject.Inject
class GetActiveUsersInteractor @Inject constructor(private val repository: ActiveUsersRepository) {
fun isActiveUserOnRepository(url: String, user: User): Boolean {
return repository.get(url).any { user_ -> user_.id == user.id }
}
fun getAllActiveUsers(url: String): List<User> {
return repository.get(url)
}
fun getActiveUserById(url: String, id: String): User? {
return repository.get(url).find { user -> user.id == id }
}
fun getActiveUserByUsername(url: String, username: String): User? {
return repository.get(url).find { user -> user.username == username }
}
}
\ No newline at end of file
package chat.rocket.android.server.domain
import chat.rocket.common.model.RoomType
import chat.rocket.core.model.Room
interface RoomRepository {
/**
* Get all rooms. Use carefully!
*
* @return All rooms or an empty list.
*/
fun getAll(): List<Room>
fun get(query: Query.() -> Unit): List<Room>
/**
* Save a single room object.
*
* @param room The room object to save.
*/
fun save(room: Room)
/**
* Save a list of rooms.
*
* @param roomList The list of rooms to save.
*/
fun saveAll(roomList: List<Room>)
/**
* Removes all rooms.
*/
fun clear()
data class Query(
var id: String? = null,
var name: String? = null,
var fullName: String? = null,
var type: RoomType? = null,
var readonly: Boolean? = null
)
}
\ No newline at end of file
package chat.rocket.android.server.domain
import chat.rocket.common.model.User
import javax.inject.Inject
class SaveActiveUsersInteractor @Inject constructor(
private val repository: ActiveUsersRepository,
private val getActiveUsersInteractor: GetActiveUsersInteractor
) {
fun save(url: String, activeUsers: List<User>) {
repository.save(url, activeUsers)
}
fun addActiveUser(url: String, user: User) {
val activeUserList: MutableList<User> =
getActiveUsersInteractor.getAllActiveUsers(url).toMutableList()
synchronized(this) {
activeUserList.add(user)
}
save(url, activeUserList)
}
fun updateActiveUser(url: String, user: User) {
getActiveUsersInteractor.getActiveUserById(url, user.id)?.let {
val newUser = User(
id = user.id,
name = user.name ?: it.name,
username = user.username ?: it.username,
status = user.status ?: it.status,
emails = user.emails ?: it.emails,
utcOffset = user.utcOffset ?: it.utcOffset,
roles = user.roles ?: it.roles
)
val activeUserList: MutableList<User> =
getActiveUsersInteractor.getAllActiveUsers(url).toMutableList()
synchronized(this) {
activeUserList.removeAll { user_ -> user_.id == user.id }
}
activeUserList.add(newUser)
save(url, activeUserList)
}
}
}
\ No newline at end of file
package chat.rocket.android.server.domain.model
data class Server(
val id: Long,
val name: String,
val url: String,
val avatar: String
)
\ No newline at end of file
package chat.rocket.android.server.infraestructure
import chat.rocket.android.server.domain.ActiveUsersRepository
import chat.rocket.common.model.User
class MemoryActiveUsersRepository : ActiveUsersRepository {
val cache = HashMap<String, List<User>>()
override fun save(url: String, activeUsers: List<User>) {
cache[url] = activeUsers
}
override fun get(url: String): List<User> = cache[url] ?: emptyList()
}
\ No newline at end of file
package chat.rocket.android.server.infraestructure
import chat.rocket.android.server.domain.RoomRepository
import chat.rocket.android.server.domain.RoomRepository.Query
import chat.rocket.core.model.Room
import java.util.concurrent.CopyOnWriteArrayList
class MemoryRoomRepository : RoomRepository {
private val rooms = CopyOnWriteArrayList<Room>()
override fun getAll() = rooms.toList()
override fun get(query: Query.() -> Unit): List<Room> {
val q = Query().apply(query)
return rooms.filter {
with(q) {
if (name != null && it.name?.contains(name!!.toRegex()) == true) return@filter false
if (fullName != null && it.fullName?.contains(fullName!!.toRegex()) == true) return@filter false
if (id != null && id == it.id) return@filter false
if (readonly != null && readonly == it.readonly) return@filter false
if (type != null && type == it.type) return@filter false
return@filter true
}
}
}
override fun save(room: Room) {
rooms.addIfAbsent(room)
}
override fun saveAll(roomList: List<Room>) {
rooms.addAllAbsent(roomList)
}
override fun clear() {
rooms.clear()
}
}
\ No newline at end of file
...@@ -17,7 +17,7 @@ dependencies { ...@@ -17,7 +17,7 @@ dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:7.2' checkstyle 'com.puppycrawl.tools:checkstyle:7.2'
} }
def qualityConfigDir = "$project.rootDir/config/quality"; def qualityConfigDir = "$project.rootDir/config/quality"
def reportsDir = "$project.buildDir/reports" def reportsDir = "$project.buildDir/reports"
check.dependsOn 'checkstyle', 'findbugs', 'pmd' check.dependsOn 'checkstyle', 'findbugs', 'pmd'
......
...@@ -267,7 +267,7 @@ object EmojiRepository { ...@@ -267,7 +267,7 @@ object EmojiRepository {
private fun loadEmojis(stream: InputStream): MutableList<Emoji> { private fun loadEmojis(stream: InputStream): MutableList<Emoji> {
val emojisJSON = JSONArray(inputStreamToString(stream)) val emojisJSON = JSONArray(inputStreamToString(stream))
val emojis = ArrayList<Emoji>(emojisJSON.length()); val emojis = ArrayList<Emoji>(emojisJSON.length())
for (i in 0 until emojisJSON.length()) { for (i in 0 until emojisJSON.length()) {
val emoji = buildEmojiFromJSON(emojisJSON.getJSONObject(i)) val emoji = buildEmojiFromJSON(emojisJSON.getJSONObject(i))
emoji?.let { emoji?.let {
......
...@@ -123,7 +123,7 @@ abstract class OverKeyboardPopupWindow( ...@@ -123,7 +123,7 @@ abstract class OverKeyboardPopupWindow(
private fun calculateScreenHeight(): Int { private fun calculateScreenHeight(): Int {
val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val display = wm.getDefaultDisplay() val display = wm.defaultDisplay
val size = Point() val size = Point()
display.getSize(size) display.getSize(size)
return size.y return size.y
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment