Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New arch] Delete public share #2544

Merged
merged 23 commits into from
Jun 3, 2019
Merged

Conversation

davigonz
Copy link
Contributor

@davigonz davigonz force-pushed the new_arch/delete_public_share branch 2 times, most recently from 2b471b0 to b7e58b8 Compare May 16, 2019 10:56
@davigonz davigonz force-pushed the new_arch/shares branch 2 times, most recently from 9421e7f to 6f24ea1 Compare May 24, 2019 11:31
@davigonz davigonz force-pushed the new_arch/delete_public_share branch from 3324c21 to 6e01457 Compare May 24, 2019 11:45
@davigonz davigonz changed the title [New arch] Delete public share [WIP] [New arch] Delete public share May 24, 2019
)
)
)
ocShareDao.insert(listOf(newPublicShare()))

Choose a reason for hiding this comment

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

Haven't you created a method for a just one item instead of a list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

private val file = mock(OCFile::class.java)
private val publicShare = mock(OCShare::class.java)
private val expirationDate = 1556575200000

Choose a reason for hiding this comment

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

When is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put a comment with the date, but do you think is really important?

Choose a reason for hiding this comment

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

I don't know if it will some years later or some years ago.... I don't know...
The problem is if the date is a coming date, it will fail tests just because we are in that date or it's past...
I would do it that date dynamically in order to avoid that issue. For example:
System. currentTimeMillis() + 2000000

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this test we are setting a date in a view and checking if it appears, so I think is not affected by a coming or past date

Copy link

@jcmontesmartos jcmontesmartos May 30, 2019

Choose a reason for hiding this comment

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

ok...

@@ -75,4 +76,11 @@ class OCRemoteSharesDataSource(
updateRemoteShareOperation.retrieveShareDetails = true
return updateRemoteShareOperation.execute(client)
}

override fun deleteShare(
remoteId: Long,

Choose a reason for hiding this comment

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

Do you use remoteId anywhere?

Choose a reason for hiding this comment

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

Ok, I've seen it below

private fun refreshSharesFromStorageManager() {
val shareFileFragment = shareFileFragment
if (shareFileFragment?.isAdded == true) { // only if added to the view hierarchy!!
shareFileFragment.refreshUsersOrGroupsListFromDB()

Choose a reason for hiding this comment

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

it would be better to have a livedata listening data from db. You will save to do this approach ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for private shares and has not been touched yet, it will be our next challenge in the architecture.

Choose a reason for hiding this comment

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

ok

}

if (!enableMultiplePublicSharing()) {
if (publicLinks?.size == 0) {

Choose a reason for hiding this comment

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

why don't you use isNullOrEmpty() ?

Choose a reason for hiding this comment

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

and the else block wouldn't have condition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* Adapter to show a list of public links
*/
class SharePublicLinkListAdapter(
private val mContext: Context, resource: Int, private val mPublicLinks: ArrayList<OCShare>?,

Choose a reason for hiding this comment

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

Why don't you put each param in a new line? Something like this:

class SharePublicLinkListAdapter(
    private val mContext: Context, 
    resource: Int, 
    private val mPublicLinks: ArrayList<OCShare>?,
    private val mListener: SharePublicLinkAdapterListener
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

) : ArrayAdapter<OCShare>(mContext, resource) {

override fun getCount(): Int {
return mPublicLinks!!.size

Choose a reason for hiding this comment

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

it can be null!!!

Choose a reason for hiding this comment

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

override fun getCount(): Int = mPublicLinks?.size ?: 0

better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, done

val share = mPublicLinks[position]

// If there's no name, set the token as name
view.publicLinkName.text = if (share.name?.isEmpty()!!) share.token else share.name

Choose a reason for hiding this comment

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

if name can be null, you can't set isEmpty as not null. That doesn't make any sense.

I would use isNullOrEmpty function instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, it does not make any sense and Android Studio keeps doing it when converting java files to kotlin 😄 , I will use if (share.name?.isEmpty() == true) instead

Choose a reason for hiding this comment

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

and why don't you use if (share.name.isNullOrEmpty()) better?

Copy link

@jcmontesmartos jcmontesmartos left a comment

Choose a reason for hiding this comment

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

LGTM now

@davigonz
Copy link
Contributor Author

Code approved, ready to test @jesmrec

@davigonz davigonz self-assigned this May 30, 2019
@jesmrec
Copy link
Collaborator

jesmrec commented May 31, 2019

Approved

@jesmrec jesmrec self-assigned this May 31, 2019
@jesmrec jesmrec self-requested a review May 31, 2019 12:23
@davigonz davigonz merged commit 3f2b230 into new_arch/shares Jun 3, 2019
@delete-merged-branch delete-merged-branch bot deleted the new_arch/delete_public_share branch June 3, 2019 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants