Skip to content

Commit

Permalink
Fixed some issues with the Load More button in group view
Browse files Browse the repository at this point in the history
  • Loading branch information
f-r00t committed Feb 26, 2024
1 parent aaf502a commit 7d0fa89
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/Groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,8 @@ export class GroupChatScreenNoTranslation extends React.Component {

groupNameValid: true,

sending: false,

messages: [],
message: "",
messageHasLength: false,
Expand All @@ -807,9 +809,9 @@ export class GroupChatScreenNoTranslation extends React.Component {
}


Globals.updateGroupsFunctions.push(() => {
Globals.updateGroupsFunctions.push(async () => {
this.setState({
messages: Globals.groupMessages
messages: await getGroupMessages(this.state.key)
})
});

Expand Down Expand Up @@ -1062,7 +1064,8 @@ export class GroupChatScreenNoTranslation extends React.Component {

this.setState({
messages: updated_messages,
messageHasLength: false
messageHasLength: false,
sending: true
});

this.setState({messageHasLength: this.state.message.length > 0});
Expand All @@ -1071,15 +1074,16 @@ export class GroupChatScreenNoTranslation extends React.Component {

if (result.success) {

updated_messages = await getGroupMessages();
updated_messages = await getGroupMessages(this.state.key);
this.setState({
messages: updated_messages,
messageHasLength: false
messageHasLength: false,
sending: false
});


} else {
updated_messages = await getGroupMessages();
updated_messages = await getGroupMessages(this.state.key);
updated_messages.push({
address: Globals.wallet.getPrimaryAddress(),
nickname: Globals.preferences.nickname,
Expand All @@ -1091,7 +1095,8 @@ export class GroupChatScreenNoTranslation extends React.Component {
});
this.setState({
messages: updated_messages,
messageHasLength: false
messageHasLength: false,
sending: false
});

}
Expand Down Expand Up @@ -1156,7 +1161,7 @@ export class GroupChatScreenNoTranslation extends React.Component {

</View>

{this.state.messages?.length > 0 && this.state.messages[0]?.count != this.state.messages?.length &&
{!this.state.sending && this.state.messages?.length > 0 && this.state.messages[0]?.count != this.state.messages?.length &&
<View style={{
flex: 1,
alignContent: 'center',
Expand All @@ -1178,7 +1183,7 @@ export class GroupChatScreenNoTranslation extends React.Component {
justifyContent: 'center'}}
onPress={async () => {

let updated_messages = await getGroupMessages(this.state.address, this.state.messages.length + 25);
let updated_messages = await getGroupMessages(this.state.key, this.state.messages.length + 25);
this.setState({
messages: updated_messages,
messageHasLength: false
Expand All @@ -1191,7 +1196,7 @@ export class GroupChatScreenNoTranslation extends React.Component {
fontSize: 12,
fontFamily: 'Montserrat-Bold'
}}>

{t('loadMore')}

</Text>
Expand Down

0 comments on commit 7d0fa89

Please sign in to comment.