This commit is contained in:
Grishka 2023-06-30 08:25:05 +03:00
parent f2aa1400c5
commit 273823a65f
4 changed files with 24 additions and 23 deletions

View File

@ -85,18 +85,18 @@ public class AccountTimelineFragment extends StatusListFragment{
loadData();
}
protected void onStatusCreated(StatusCreatedEvent ev){
if(!AccountSessionManager.getInstance().isSelf(accountID, ev.status.account))
protected void onStatusCreated(Status status){
if(!AccountSessionManager.getInstance().isSelf(accountID, status.account))
return;
if(filter==GetAccountStatuses.Filter.DEFAULT){
// Keep replies to self, discard all other replies
if(ev.status.inReplyToAccountId!=null && !ev.status.inReplyToAccountId.equals(AccountSessionManager.getInstance().getAccount(accountID).self.id))
if(status.inReplyToAccountId!=null && !status.inReplyToAccountId.equals(AccountSessionManager.getInstance().getAccount(accountID).self.id))
return;
}else if(filter==GetAccountStatuses.Filter.MEDIA){
if(ev.status.mediaAttachments.isEmpty())
if(status.mediaAttachments.isEmpty())
return;
}
prependItems(Collections.singletonList(ev.status), true);
prependItems(Collections.singletonList(status), true);
}
@Override

View File

@ -167,8 +167,8 @@ public class HomeTimelineFragment extends StatusListFragment{
}
}
public void onStatusCreated(StatusCreatedEvent ev){
prependItems(Collections.singletonList(ev.status), true);
public void onStatusCreated(Status status){
prependItems(Collections.singletonList(status), true);
}
private void onFabClick(View v){

View File

@ -63,26 +63,26 @@ public abstract class StatusListFragment extends BaseStatusListFragment<Status>{
Nav.go(getActivity(), ThreadFragment.class, args);
}
protected void onStatusCreated(StatusCreatedEvent ev){}
protected void onStatusCreated(Status status){}
protected void onStatusUpdated(StatusUpdatedEvent ev){
protected void onStatusUpdated(Status status){
ArrayList<Status> statusesForDisplayItems=new ArrayList<>();
for(int i=0;i<data.size();i++){
Status s=data.get(i);
if(s.reblog!=null && s.reblog.id.equals(ev.status.id)){
s.reblog=ev.status;
if(s.reblog!=null && s.reblog.id.equals(status.id)){
s.reblog=status.clone();
statusesForDisplayItems.add(s);
}else if(s.id.equals(ev.status.id)){
data.set(i, ev.status);
statusesForDisplayItems.add(ev.status);
}else if(s.id.equals(status.id)){
data.set(i, status);
statusesForDisplayItems.add(status);
}
}
for(int i=0;i<preloadedData.size();i++){
Status s=preloadedData.get(i);
if(s.reblog!=null && s.reblog.id.equals(ev.status.id)){
s.reblog=ev.status;
}else if(s.id.equals(ev.status.id)){
preloadedData.set(i, ev.status);
if(s.reblog!=null && s.reblog.id.equals(status.id)){
s.reblog=status.clone();
}else if(s.id.equals(status.id)){
preloadedData.set(i, status);
}
}
@ -209,12 +209,12 @@ public abstract class StatusListFragment extends BaseStatusListFragment<Status>{
public void onStatusCreated(StatusCreatedEvent ev){
if(!ev.accountID.equals(accountID))
return;
StatusListFragment.this.onStatusCreated(ev);
StatusListFragment.this.onStatusCreated(ev.status.clone());
}
@Subscribe
public void onStatusUpdated(StatusUpdatedEvent ev){
StatusListFragment.this.onStatusUpdated(ev);
StatusListFragment.this.onStatusUpdated(ev.status);
}
@Subscribe

View File

@ -125,9 +125,10 @@ public class ThreadFragment extends StatusListFragment{
footerProgress.setVisibility(View.VISIBLE);
}
protected void onStatusCreated(StatusCreatedEvent ev){
if(ev.status.inReplyToId!=null && getStatusByID(ev.status.inReplyToId)!=null){
onAppendItems(Collections.singletonList(ev.status));
protected void onStatusCreated(Status status){
if(status.inReplyToId!=null && getStatusByID(status.inReplyToId)!=null){
onAppendItems(Collections.singletonList(status));
data.add(status);
}
}