Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ public int getItemPosition(@NonNull OCFile file) {
return position;
}

public void setFavoriteAttributeForItemID(String fileId, boolean favorite, boolean removeFromList) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method should be renamed to setFavoriteAttributeForRemotePath

public void setFavoriteAttributeForItemID(String remotePath, boolean favorite, boolean removeFromList) {
for (OCFile file : mFiles) {
if (file.getRemoteId().equals(fileId)) {
if (file.getRemotePath().equals(remotePath)) {
file.setFavorite(favorite);

if (removeFromList) {
Expand All @@ -231,7 +231,7 @@ public void setFavoriteAttributeForItemID(String fileId, boolean favorite, boole
}

for (OCFile file : mFilesAll) {
if (file.getRemoteId().equals(fileId)) {
if (file.getRemoteId().equals(remotePath)) {
file.setFavorite(favorite);

mStorageManager.saveFile(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ object OCShareToOCFileConverter {
isPreviewAvailable = firstShare.isHasPreview
mimeType = firstShare.mimetype
note = firstShare.note
fileId = firstShare.fileSource
remoteId = firstShare.remoteId.toString()
remoteId = firstShare.fileSource.toString()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit confusing. Why are we setting remoteId from OCShare.fileSource and not from OCShare.remoteId? It may make sense to add a comment to explain why

isFavorite = firstShare.isFavorite
// use first share timestamp as timestamp
firstShareTimestamp = shares.minOf { it.sharedDate * MILLIS_PER_SECOND }
// don't have file length or mod timestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import android.widget.AbsListView;
import android.widget.Toast;

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
Expand Down Expand Up @@ -1583,7 +1582,7 @@ public void onMessageEvent(FavoriteEvent event) {

if (remoteOperationResult.isSuccess()) {
boolean removeFromList = currentSearchType == SearchType.FAVORITE_SEARCH && !event.shouldFavorite;
mAdapter.setFavoriteAttributeForItemID(event.remoteId, event.shouldFavorite, removeFromList);
mAdapter.setFavoriteAttributeForItemID(event.remotePath, event.shouldFavorite, removeFromList);
}

} catch (ClientFactory.CreationException e) {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
daggerVersion = "2.43.2"
markwonVersion = "4.6.2"
prismVersion = "2.0.0"
androidLibraryVersion = "master-SNAPSHOT"
androidLibraryVersion = "shareAPIfavorite-SNAPSHOT"
mockitoVersion = "4.8.0"
mockitoKotlinVersion = "4.0.0"
mockkVersion = "1.12.5"
Expand Down