Skip to content

Commit

Permalink
catch an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Oct 22, 2023
1 parent 858ac30 commit 6a532ea
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main/kotlin/com/zoffcc/applications/trifa2/MessageReducer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ fun chatReducer(state: MessageState, action: MessageAction): MessageState = when
is MessageAction.UpdateMessage ->
{
val TAG = "UpdateMessage"
val item_position = state.messages.binarySearchBy(action.message_db.id) { it.id }
// Log.i(TAG, "item_position = " + item_position)
val item = state.messages[item_position]
if (action.filetransfer_db != null)
try
{
state.messages[item_position] = item.copy(
filesize = action.filetransfer_db.filesize,
currentfilepos = action.filetransfer_db.current_position,
filename_fullpath = action.message_db.filename_fullpath
)
val item_position = state.messages.binarySearchBy(action.message_db.id) { it.id } // Log.i(TAG, "item_position = " + item_position)
val item = state.messages[item_position]
if (action.filetransfer_db != null)
{
state.messages[item_position] = item.copy(filesize = action.filetransfer_db.filesize, currentfilepos = action.filetransfer_db.current_position, filename_fullpath = action.message_db.filename_fullpath)
} else
{
Log.i(TAG, "UpdateMessage:ft=null");
state.messages[item_position] = item.copy(filename_fullpath = null, currentfilepos = 0, filesize = 0)
}
}
else
catch (e: Exception)
{
Log.i(TAG, "UpdateMessage:ft=null");
state.messages[item_position] = item.copy(filename_fullpath = null, currentfilepos = 0, filesize = 0)
}
state.copy(messages = state.messages)
}
Expand Down

0 comments on commit 6a532ea

Please sign in to comment.