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
1f996b5f
Commit
1f996b5f
authored
Apr 29, 2019
by
Hussein El Feky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformatted code
parent
094e076d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
24 deletions
+37
-24
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+31
-13
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+6
-11
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
1f996b5f
...
@@ -224,7 +224,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -224,7 +224,7 @@ class ChatRoomPresenter @Inject constructor(
isBroadcast
=
chatIsBroadcast
,
isRoom
=
true
isBroadcast
=
chatIsBroadcast
,
isRoom
=
true
)
)
)
)
lastMessageId
=
localMessages
.
first
()
.
id
lastMessageId
=
localMessages
.
first
OrNull
()
?
.
id
val
lastSyncDate
=
messagesRepository
.
getLastSyncDate
(
chatRoomId
)
val
lastSyncDate
=
messagesRepository
.
getLastSyncDate
(
chatRoomId
)
if
(
oldMessages
.
isNotEmpty
()
&&
lastSyncDate
!=
null
)
{
if
(
oldMessages
.
isNotEmpty
()
&&
lastSyncDate
!=
null
)
{
view
.
showMessages
(
oldMessages
,
clearDataSet
)
view
.
showMessages
(
oldMessages
,
clearDataSet
)
...
@@ -237,7 +237,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -237,7 +237,7 @@ class ChatRoomPresenter @Inject constructor(
}
}
// TODO: For now we are marking the room as read if we can get the messages (I mean, no exception occurs)
// TODO: For now we are marking the room as read if we can get the messages (I mean, no exception occurs)
// but should mark only when the user see the first unread message.
// but should mark only when the user see
s
the first unread message.
markRoomAsRead
(
chatRoomId
)
markRoomAsRead
(
chatRoomId
)
subscribeMessages
(
chatRoomId
)
subscribeMessages
(
chatRoomId
)
...
@@ -1079,7 +1079,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1079,7 +1079,7 @@ class ChatRoomPresenter @Inject constructor(
/**
/**
* Send an emoji reaction to a message.
* Send an emoji reaction to a message.
*/
*/
fun
react
(
messageId
:
String
,
emoji
:
String
,
roomId
:
String
)
{
fun
react
(
messageId
:
String
,
emoji
:
String
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
retryIO
(
"toggleEmoji($messageId, $emoji)"
)
{
retryIO
(
"toggleEmoji($messageId, $emoji)"
)
{
...
@@ -1088,10 +1088,31 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1088,10 +1088,31 @@ class ChatRoomPresenter @Inject constructor(
logReactionEvent
()
logReactionEvent
()
}
catch
(
ex
:
RocketChatException
)
{
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
Timber
.
e
(
ex
)
// emoji is not valid, post it
}
sendMessage
(
roomId
,
"+$emoji"
,
null
)
}
}
finally
{
}
view
.
clearMessageComposition
(
true
)
fun
reactToLastMessage
(
text
:
String
,
roomId
:
String
)
{
launchUI
(
strategy
)
{
lastMessageId
?.
let
{
messageId
->
val
emoji
=
text
.
substring
(
1
).
trimEnd
()
if
(
emoji
.
length
>=
2
&&
emoji
.
startsWith
(
":"
)
&&
emoji
.
endsWith
(
":"
))
{
try
{
retryIO
(
"toggleEmoji($messageId, $emoji)"
)
{
client
.
toggleReaction
(
messageId
,
emoji
.
removeSurrounding
(
":"
))
}
logReactionEvent
()
view
.
clearMessageComposition
(
true
)
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
// emoji is not valid, post it
sendMessage
(
roomId
,
text
,
null
)
}
}
else
{
sendMessage
(
roomId
,
text
,
null
)
}
}.
ifNull
{
sendMessage
(
roomId
,
text
,
null
)
}
}
}
}
}
}
...
@@ -1180,7 +1201,9 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1180,7 +1201,9 @@ class ChatRoomPresenter @Inject constructor(
val
result
=
retryIO
(
"runCommand($name, $params, $roomId)"
)
{
val
result
=
retryIO
(
"runCommand($name, $params, $roomId)"
)
{
client
.
runCommand
(
Command
(
name
,
params
),
roomId
)
client
.
runCommand
(
Command
(
name
,
params
),
roomId
)
}
}
if
(!
result
)
{
if
(
result
)
{
view
.
clearMessageComposition
(
true
)
}
else
{
// failed, command is not valid so post it
// failed, command is not valid so post it
sendMessage
(
roomId
,
text
,
null
)
sendMessage
(
roomId
,
text
,
null
)
}
}
...
@@ -1190,7 +1213,6 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1190,7 +1213,6 @@ class ChatRoomPresenter @Inject constructor(
// command is not valid, post it
// command is not valid, post it
sendMessage
(
roomId
,
text
,
null
)
sendMessage
(
roomId
,
text
,
null
)
}
finally
{
}
finally
{
view
.
clearMessageComposition
(
true
)
view
.
enableSendMessageButton
()
view
.
enableSendMessageButton
()
}
}
}
}
...
@@ -1304,8 +1326,4 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1304,8 +1326,4 @@ class ChatRoomPresenter @Inject constructor(
fun
getDraftUnfinishedMessage
():
String
?
{
fun
getDraftUnfinishedMessage
():
String
?
{
return
localRepository
.
get
(
draftKey
)
return
localRepository
.
get
(
draftKey
)
}
}
fun
getLastMessageId
():
String
?
{
return
lastMessageId
}
}
}
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
1f996b5f
...
@@ -476,21 +476,16 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -476,21 +476,16 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
}
}
override
fun
sendMessage
(
text
:
String
)
{
override
fun
sendMessage
(
text
:
String
)
{
ui
{
ui
{
if
(!
text
.
isBlank
())
{
if
(!
text
.
isBlank
())
{
if
(
text
.
startsWith
(
"/"
))
{
if
(
text
.
startsWith
(
"/"
))
{
presenter
.
runCommand
(
text
,
chatRoomId
)
presenter
.
runCommand
(
text
,
chatRoomId
)
return
@ui
}
else
if
(
text
.
startsWith
(
"+"
))
{
}
else
if
(
text
.
startsWith
(
"+"
)
&&
presenter
.
getLastMessageId
()
!=
null
)
{
presenter
.
reactToLastMessage
(
text
,
chatRoomId
)
val
trimmedText
=
text
.
substring
(
1
).
trimEnd
()
}
else
{
if
(
trimmedText
.
length
-
trimmedText
.
removeSurrounding
(
":"
).
length
==
2
)
{
presenter
.
sendMessage
(
chatRoomId
,
text
,
editingMessageId
)
presenter
.
react
(
presenter
.
getLastMessageId
()
!!
,
trimmedText
,
chatRoomId
)
return
@ui
}
}
}
presenter
.
sendMessage
(
chatRoomId
,
text
,
editingMessageId
)
}
}
}
}
}
}
...
@@ -680,11 +675,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -680,11 +675,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
onReactionTouched
(
messageId
:
String
,
emojiShortname
:
String
)
{
override
fun
onReactionTouched
(
messageId
:
String
,
emojiShortname
:
String
)
{
presenter
.
react
(
messageId
,
emojiShortname
,
chatRoomId
)
presenter
.
react
(
messageId
,
emojiShortname
)
}
}
override
fun
onReactionAdded
(
messageId
:
String
,
emoji
:
Emoji
)
{
override
fun
onReactionAdded
(
messageId
:
String
,
emoji
:
Emoji
)
{
presenter
.
react
(
messageId
,
emoji
.
shortname
,
chatRoomId
)
presenter
.
react
(
messageId
,
emoji
.
shortname
)
}
}
override
fun
onReactionLongClicked
(
override
fun
onReactionLongClicked
(
...
...
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