Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
540cc085
Commit
540cc085
authored
Nov 19, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More retryDB
parent
c3037e3e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
118 additions
and
100 deletions
+118
-100
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+71
-66
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+2
-1
DatabaseManager.kt
app/src/main/java/chat/rocket/android/db/DatabaseManager.kt
+2
-2
FavoriteMessagesPresenter.kt
...avoritemessages/presentation/FavoriteMessagesPresenter.kt
+11
-8
FilesPresenter.kt
.../chat/rocket/android/files/presentation/FilesPresenter.kt
+10
-7
MembersPresenter.kt
...t/rocket/android/members/presentation/MembersPresenter.kt
+11
-8
PinnedMessagesPresenter.kt
...id/pinnedmessages/presentation/PinnedMessagesPresenter.kt
+11
-8
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
540cc085
...
@@ -39,6 +39,7 @@ import chat.rocket.android.util.extension.getByteArray
...
@@ -39,6 +39,7 @@ import chat.rocket.android.util.extension.getByteArray
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.extensions.exhaustive
import
chat.rocket.android.util.extensions.exhaustive
import
chat.rocket.android.util.retryDB
import
chat.rocket.android.util.retryIO
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.RoomType
...
@@ -138,7 +139,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -138,7 +139,7 @@ class ChatRoomPresenter @Inject constructor(
}
finally
{
}
finally
{
// User has at least an 'owner' or 'moderator' role.
// User has at least an 'owner' or 'moderator' role.
val
userCanMod
=
isOwnerOrMod
()
val
userCanMod
=
isOwnerOrMod
()
val
chatRoom
=
dbManager
.
getRoom
(
roomId
)
val
chatRoom
=
retryDB
(
"getRoom($roomId)"
)
{
dbManager
.
getRoom
(
roomId
)
}
val
muted
=
chatRoom
?.
chatRoom
?.
muted
?:
emptyList
()
val
muted
=
chatRoom
?.
chatRoom
?.
muted
?:
emptyList
()
// Can post anyway if has the 'post-readonly' permission on server.
// Can post anyway if has the 'post-readonly' permission on server.
val
userCanPost
=
userCanMod
||
permissions
.
canPostToReadOnlyChannels
()
||
val
userCanPost
=
userCanMod
||
permissions
.
canPostToReadOnlyChannels
()
||
...
@@ -904,7 +905,8 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -904,7 +905,8 @@ class ChatRoomPresenter @Inject constructor(
// TODO: move this to new interactor or FetchChatRoomsInteractor?
// TODO: move this to new interactor or FetchChatRoomsInteractor?
private
suspend
fun
getChatRoomAsync
(
roomId
:
String
):
ChatRoom
?
=
withContext
(
CommonPool
)
{
private
suspend
fun
getChatRoomAsync
(
roomId
:
String
):
ChatRoom
?
=
withContext
(
CommonPool
)
{
return
@withContext
dbManager
.
chatRoomDao
().
get
(
roomId
)
?.
let
{
retryDB
(
"getRoom($roomId)"
)
{
dbManager
.
chatRoomDao
().
get
(
roomId
)
?.
let
{
with
(
it
.
chatRoom
)
{
with
(
it
.
chatRoom
)
{
ChatRoom
(
ChatRoom
(
id
=
id
,
id
=
id
,
...
@@ -937,10 +939,12 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -937,10 +939,12 @@ class ChatRoomPresenter @Inject constructor(
}
}
}
}
}
}
}
// TODO: move this to new interactor or FetchChatRoomsInteractor?
// TODO: move this to new interactor or FetchChatRoomsInteractor?
private
suspend
fun
getChatRoomsAsync
(
name
:
String
?
=
null
):
List
<
ChatRoom
>
=
withContext
(
CommonPool
)
{
private
suspend
fun
getChatRoomsAsync
(
name
:
String
?
=
null
):
List
<
ChatRoom
>
=
withContext
(
CommonPool
)
{
return
@withContext
dbManager
.
chatRoomDao
().
getAllSync
().
filter
{
retryDB
(
"getAllSync()"
)
{
dbManager
.
chatRoomDao
().
getAllSync
().
filter
{
if
(
name
==
null
)
{
if
(
name
==
null
)
{
return
@filter
true
return
@filter
true
}
}
...
@@ -978,6 +982,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -978,6 +982,7 @@ class ChatRoomPresenter @Inject constructor(
}
}
}
}
}
}
}
fun
joinChat
(
chatRoomId
:
String
)
{
fun
joinChat
(
chatRoomId
:
String
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
...
...
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
540cc085
...
@@ -13,6 +13,7 @@ import chat.rocket.android.server.domain.useRealName
...
@@ -13,6 +13,7 @@ import chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.server.domain.useSpecialCharsOnRoom
import
chat.rocket.android.server.domain.useSpecialCharsOnRoom
import
chat.rocket.android.server.infraestructure.ConnectionManager
import
chat.rocket.android.server.infraestructure.ConnectionManager
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.retryDB
import
chat.rocket.android.util.retryIO
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.RoomType
...
@@ -45,7 +46,7 @@ class ChatRoomsPresenter @Inject constructor(
...
@@ -45,7 +46,7 @@ class ChatRoomsPresenter @Inject constructor(
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
view
.
showLoadingRoom
(
chatRoom
.
name
)
view
.
showLoadingRoom
(
chatRoom
.
name
)
try
{
try
{
val
room
=
dbManager
.
getRoom
(
chatRoom
.
id
)
val
room
=
retryDB
(
"getRoom(${chatRoom.id}"
)
{
dbManager
.
getRoom
(
chatRoom
.
id
)
}
if
(
room
!=
null
)
{
if
(
room
!=
null
)
{
loadChatRoom
(
room
.
chatRoom
,
true
)
loadChatRoom
(
room
.
chatRoom
,
true
)
}
else
{
}
else
{
...
...
app/src/main/java/chat/rocket/android/db/DatabaseManager.kt
View file @
540cc085
...
@@ -92,8 +92,8 @@ class DatabaseManager(val context: Application, val serverUrl: String) {
...
@@ -92,8 +92,8 @@ class DatabaseManager(val context: Application, val serverUrl: String) {
}
}
}
}
fun
logout
()
{
suspend
fun
logout
()
{
database
.
clearAllTables
()
retryDB
(
"clearAllTables"
)
{
database
.
clearAllTables
()
}
}
}
suspend
fun
getRoom
(
id
:
String
)
=
withContext
(
dbManagerContext
)
{
suspend
fun
getRoom
(
id
:
String
)
=
withContext
(
dbManagerContext
)
{
...
...
app/src/main/java/chat/rocket/android/favoritemessages/presentation/FavoriteMessagesPresenter.kt
View file @
540cc085
...
@@ -5,6 +5,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
...
@@ -5,6 +5,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.retryDB
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.common.util.ifNull
...
@@ -34,6 +35,7 @@ class FavoriteMessagesPresenter @Inject constructor(
...
@@ -34,6 +35,7 @@ class FavoriteMessagesPresenter @Inject constructor(
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
retryDB
(
"getRoom($roomId)"
)
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
val
favoriteMessages
=
val
favoriteMessages
=
client
.
getFavoriteMessages
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
)
client
.
getFavoriteMessages
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
)
...
@@ -43,6 +45,7 @@ class FavoriteMessagesPresenter @Inject constructor(
...
@@ -43,6 +45,7 @@ class FavoriteMessagesPresenter @Inject constructor(
}.
ifNull
{
}.
ifNull
{
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server."
)
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server."
)
}
}
}
}
catch
(
exception
:
RocketChatException
)
{
}
catch
(
exception
:
RocketChatException
)
{
Timber
.
e
(
exception
)
Timber
.
e
(
exception
)
}
finally
{
}
finally
{
...
...
app/src/main/java/chat/rocket/android/files/presentation/FilesPresenter.kt
View file @
540cc085
...
@@ -7,6 +7,7 @@ import chat.rocket.android.files.uimodel.FileUiModel
...
@@ -7,6 +7,7 @@ import chat.rocket.android.files.uimodel.FileUiModel
import
chat.rocket.android.files.uimodel.FileUiModelMapper
import
chat.rocket.android.files.uimodel.FileUiModelMapper
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.retryDB
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.common.util.ifNull
...
@@ -36,6 +37,7 @@ class FilesPresenter @Inject constructor(
...
@@ -36,6 +37,7 @@ class FilesPresenter @Inject constructor(
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
retryDB
(
"getRoom($roomId)"
)
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
val
files
=
client
.
getFiles
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
)
val
files
=
client
.
getFiles
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
)
val
filesUiModel
=
mapper
.
mapToUiModelList
(
files
.
result
)
val
filesUiModel
=
mapper
.
mapToUiModelList
(
files
.
result
)
...
@@ -44,6 +46,7 @@ class FilesPresenter @Inject constructor(
...
@@ -44,6 +46,7 @@ class FilesPresenter @Inject constructor(
}.
ifNull
{
}.
ifNull
{
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server."
)
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server."
)
}
}
}
}
catch
(
exception
:
RocketChatException
)
{
}
catch
(
exception
:
RocketChatException
)
{
exception
.
message
?.
let
{
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
view
.
showMessage
(
it
)
...
...
app/src/main/java/chat/rocket/android/members/presentation/MembersPresenter.kt
View file @
540cc085
...
@@ -6,6 +6,7 @@ import chat.rocket.android.members.uimodel.MemberUiModel
...
@@ -6,6 +6,7 @@ import chat.rocket.android.members.uimodel.MemberUiModel
import
chat.rocket.android.members.uimodel.MemberUiModelMapper
import
chat.rocket.android.members.uimodel.MemberUiModelMapper
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.retryDB
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.common.util.ifNull
...
@@ -36,6 +37,7 @@ class MembersPresenter @Inject constructor(
...
@@ -36,6 +37,7 @@ class MembersPresenter @Inject constructor(
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
retryDB
(
"getRoom($roomId)"
)
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
val
members
=
val
members
=
client
.
getMembers
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
,
60
)
client
.
getMembers
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
,
60
)
...
@@ -45,6 +47,7 @@ class MembersPresenter @Inject constructor(
...
@@ -45,6 +47,7 @@ class MembersPresenter @Inject constructor(
}.
ifNull
{
}.
ifNull
{
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server."
)
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server."
)
}
}
}
}
catch
(
exception
:
RocketChatException
)
{
}
catch
(
exception
:
RocketChatException
)
{
exception
.
message
?.
let
{
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
view
.
showMessage
(
it
)
...
...
app/src/main/java/chat/rocket/android/pinnedmessages/presentation/PinnedMessagesPresenter.kt
View file @
540cc085
...
@@ -5,6 +5,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
...
@@ -5,6 +5,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.retryDB
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.common.util.ifNull
...
@@ -34,6 +35,7 @@ class PinnedMessagesPresenter @Inject constructor(
...
@@ -34,6 +35,7 @@ class PinnedMessagesPresenter @Inject constructor(
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
retryDB
(
"getRoom($roomId)"
)
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
val
pinnedMessages
=
val
pinnedMessages
=
client
.
getPinnedMessages
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
)
client
.
getPinnedMessages
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
)
...
@@ -43,6 +45,7 @@ class PinnedMessagesPresenter @Inject constructor(
...
@@ -43,6 +45,7 @@ class PinnedMessagesPresenter @Inject constructor(
}.
ifNull
{
}.
ifNull
{
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server."
)
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server."
)
}
}
}
}
catch
(
exception
:
RocketChatException
)
{
}
catch
(
exception
:
RocketChatException
)
{
Timber
.
e
(
exception
)
Timber
.
e
(
exception
)
}
finally
{
}
finally
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment