зеркало из https://github.com/nextcloud/spreed.git
Merge pull request #4439 from nextcloud/techdebt/noid/dont-copy-messages-array
Don't copy array for reverse iteration
This commit is contained in:
Коммит
0e23e2e32d
|
@ -596,14 +596,13 @@ export default {
|
|||
* @returns {string} The last known message id.
|
||||
*/
|
||||
getLastKnownMessageId() {
|
||||
// Reverse a copy of the messages array
|
||||
const reversedMessages = this.messagesList.slice().reverse()
|
||||
// Get the id of the last non-temporary message
|
||||
for (const message of reversedMessages) {
|
||||
const id = message.id.toString()
|
||||
if (!id.startsWith('temp-')) {
|
||||
return id
|
||||
let i = this.messagesList.length - 1
|
||||
|
||||
while (i >= 0) {
|
||||
if (!this.messagesList[i].id.toString().startsWith('temp-')) {
|
||||
return this.messagesList[i].id
|
||||
}
|
||||
i--
|
||||
}
|
||||
return '0'
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче