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
36a7c349
Commit
36a7c349
authored
May 02, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load permissions just after loading list of chats
parent
f0b85b9f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
5 deletions
+29
-5
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+7
-1
ChatRoomView.kt
...chat/rocket/android/chatroom/presentation/ChatRoomView.kt
+2
-0
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+5
-1
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+3
-1
PermissionsInteractor.kt
...hat/rocket/android/server/domain/PermissionsInteractor.kt
+12
-2
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
36a7c349
...
...
@@ -70,10 +70,16 @@ class ChatRoomPresenter @Inject constructor(
private
val
stateChannel
=
Channel
<
State
>()
private
var
lastState
=
manager
.
state
fun
setupChatRoom
()
{
launchUI
(
strategy
)
{
val
canPost
=
permissions
.
canPostToReadOnlyChannels
()
view
.
onRoomChanged
(
canPost
)
}
}
fun
loadMessages
(
chatRoomId
:
String
,
chatRoomType
:
String
,
offset
:
Long
=
0
)
{
this
.
chatRoomId
=
chatRoomId
this
.
chatRoomType
=
chatRoomType
println
(
permissions
.
canPostToReadOnlyChannels
())
launchUI
(
strategy
)
{
view
.
showLoading
()
try
{
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomView.kt
View file @
36a7c349
...
...
@@ -120,4 +120,6 @@ interface ChatRoomView : LoadingView, MessageView {
* @param commands The list of available commands.
*/
fun
populateCommandSuggestions
(
commands
:
List
<
CommandSuggestionViewModel
>)
fun
onRoomChanged
(
canPost
:
Boolean
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
36a7c349
...
...
@@ -124,11 +124,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
super
.
onViewCreated
(
view
,
savedInstanceState
)
setupToolbar
(
chatRoomName
)
presenter
.
setupChatRoom
()
presenter
.
loadMessages
(
chatRoomId
,
chatRoomType
)
presenter
.
loadChatRooms
()
setupRecyclerView
()
setupFab
()
setupMessageComposer
()
setupSuggestionsView
()
setupActionSnackbar
()
activity
?.
apply
{
...
...
@@ -227,6 +227,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
onRoomChanged
(
canPost
:
Boolean
)
{
setupMessageComposer
()
}
private
fun
toggleNoChatView
(
size
:
Int
)
{
if
(
size
==
0
){
image_chat_icon
.
setVisible
(
true
)
...
...
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
36a7c349
...
...
@@ -66,12 +66,13 @@ class ChatRoomsPresenter @Inject constructor(
view
.
showLoading
()
subscribeStatusChange
()
try
{
permissionsInteractor
.
saveAll
(
client
.
permissions
())
// If we still don't have 'Store_Last_Message' setting, refresh the settings
if
(!
settings
.
hasShowLastMessage
())
{
refreshSettingsInteractor
.
refresh
(
currentServer
)
}
view
.
updateChatRooms
(
getUserChatRooms
())
val
permissions
=
retryIO
{
client
.
permissions
()
}
permissionsInteractor
.
saveAll
(
permissions
)
}
catch
(
ex
:
RocketChatException
)
{
ex
.
message
?.
let
{
view
.
showMessage
(
it
)
...
...
@@ -96,6 +97,7 @@ class ChatRoomsPresenter @Inject constructor(
chatRoom
.
name
}
println
(
"Owner -> ${chatRoom.user}"
)
navigator
.
toChatRoom
(
chatRoom
.
id
,
roomName
,
chatRoom
.
type
.
toString
(),
chatRoom
.
readonly
?:
false
,
chatRoom
.
lastSeen
?:
-
1
,
...
...
app/src/main/java/chat/rocket/android/server/domain/PermissionsInteractor.kt
View file @
36a7c349
package
chat.rocket.android.server.domain
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.common.model.User
import
chat.rocket.core.model.Permission
import
javax.inject.Inject
...
...
@@ -57,12 +58,21 @@ class PermissionsInteractor @Inject constructor(
fun
canPostToReadOnlyChannels
():
Boolean
{
val
url
=
getCurrentServerUrl
()
!!
val
currentUserRoles
=
localRepository
.
getCurrentUser
(
url
)
?.
roles
val
currentUserRoles
=
currentUser
(
)
?.
roles
return
permissionsRepository
.
get
(
url
,
POST_READONLY
)
?.
let
{
permission
->
currentUserRoles
?.
isNotEmpty
()
==
true
&&
permission
.
roles
.
any
{
currentUserRoles
.
contains
(
it
)
}
}
==
true
}
==
true
||
isAdmin
()
}
private
fun
currentUser
():
User
?
{
val
url
=
getCurrentServerUrl
()
!!
return
localRepository
.
getCurrentUser
(
url
)
}
private
fun
isAdmin
():
Boolean
{
return
currentUser
()
?.
roles
?.
find
{
it
.
equals
(
"admin"
,
ignoreCase
=
true
)
}
!=
null
}
private
fun
getCurrentServerUrl
():
String
?
{
...
...
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