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(); loadData();
} }
protected void onStatusCreated(StatusCreatedEvent ev){ protected void onStatusCreated(Status status){
if(!AccountSessionManager.getInstance().isSelf(accountID, ev.status.account)) if(!AccountSessionManager.getInstance().isSelf(accountID, status.account))
return; return;
if(filter==GetAccountStatuses.Filter.DEFAULT){ if(filter==GetAccountStatuses.Filter.DEFAULT){
// Keep replies to self, discard all other replies // 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; return;
}else if(filter==GetAccountStatuses.Filter.MEDIA){ }else if(filter==GetAccountStatuses.Filter.MEDIA){
if(ev.status.mediaAttachments.isEmpty()) if(status.mediaAttachments.isEmpty())
return; return;
} }
prependItems(Collections.singletonList(ev.status), true); prependItems(Collections.singletonList(status), true);
} }
@Override @Override

View File

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

View File

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

View File

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