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

#8: Separate user-defined properties into dedicated storage #18

Merged
merged 14 commits into from
Oct 25, 2023

Conversation

shubertm
Copy link
Member

@shubertm shubertm commented Sep 28, 2023

@shubertm shubertm requested a review from kirillt September 28, 2023 12:33
app/build.gradle Outdated Show resolved Hide resolved
@kirillt kirillt requested a review from mdrlzy September 28, 2023 14:17
@shubertm shubertm temporarily deployed to Development September 29, 2023 10:52 — with GitHub Actions Inactive
@shubertm shubertm requested a review from kirillt September 29, 2023 13:19
@kirillt kirillt changed the title #8: Separate user metadata into dedicated storage #8: Separate user-defined properties into dedicated storage Sep 30, 2023
@shubertm shubertm temporarily deployed to Development October 2, 2023 06:40 — with GitHub Actions Inactive
@kirillt
Copy link
Member

kirillt commented Oct 6, 2023

We have small bug here.

Steps to reproduce:

  1. Create several notes or open a folder with existing notes.
  2. Create new note, e.g. "abc". Press save.
  3. The new note is displayed in the list.
  4. Tap it to open.
  5. Go back.
  6. The list lacks new "abc" note.
  7. Open any note. Go back.
  8. The note is there again.

@shubertm shubertm temporarily deployed to Development October 8, 2023 07:52 — with GitHub Actions Inactive
@kirillt
Copy link
Member

kirillt commented Oct 21, 2023

The bug with disappearing notes is fixed now. I've updated ark-filepicker dependency to take it from GitHub Packages.

@kirillt kirillt temporarily deployed to Development October 21, 2023 05:46 — with GitHub Actions Inactive
@kirillt
Copy link
Member

kirillt commented Oct 21, 2023

Feel free to merge as soon as @hieuwu puts a green tick.

@shubertm
Copy link
Member Author

Feel free to merge as soon as @hieuwu puts a green tick.

Alright

@hieuwu
Copy link
Collaborator

hieuwu commented Oct 21, 2023

Please also update screenshot before and after change to make sure feature still works well as we don't have test in this repo yet

@shubertm
Copy link
Member Author

Please also update screenshot before and after change to make sure feature still works well as we don't have test in this repo yet

This feature has no UI, is in the data layer. Or ma you explain?

@hieuwu
Copy link
Collaborator

hieuwu commented Oct 21, 2023

Please also update screenshot before and after change to make sure feature still works well as we don't have test in this repo yet

This feature has no UI, is in the data layer. Or ma you explain?

No worries. All good

@shubertm shubertm temporarily deployed to Development October 22, 2023 10:12 — with GitHub Actions Inactive
@shubertm shubertm temporarily deployed to Development October 22, 2023 10:14 — with GitHub Actions Inactive
Comment on lines 124 to 126
} catch (e: Exception) {
e.printStackTrace()
}
Copy link
Member

Choose a reason for hiding this comment

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

Can any exceptions really occur here? If try-catch is necessary, then better to log at warning level, not just print.

@hieuwu Please correct me if I'm wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The path.deleteIfExists() inside delete method will throw IOException. I think that's why he wrap it in try catch block.

Comment on lines 87 to 89
} catch (e: Exception) {
e.printStackTrace()
}
Copy link
Member

Choose a reason for hiding this comment

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

What exceptions can occur here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Initial implementation was throwing IOException, since we changed to new kotlin extension function forEachLine I think we can remove the block

import javax.inject.Inject

@HiltViewModel
class EditTextNotesViewModel @Inject constructor(): ViewModel() {

private val iODispatcher = Dispatchers.IO

@Inject lateinit var repo: TextNotesRepository
@Inject lateinit var repo: TextNotesRepo
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please inject dependencies in constructor

Comment on lines 124 to 126
} catch (e: Exception) {
e.printStackTrace()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The path.deleteIfExists() inside delete method will throw IOException. I think that's why he wrap it in try catch block.

e.printStackTrace()
}
}
this.coroutineContext.job
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we return an job object when we don't do anything with it? Using an Unit function is good enough in this case

Copy link
Member Author

Choose a reason for hiding this comment

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

I was using it locally, just forgot to remove it :)

Comment on lines 33 to 34
private val _textNotes = MutableStateFlow(listOf<TextNote>())
val textNotes: StateFlow<List<TextNote>> = _textNotes
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please do not keep state in repository layer. Repsitory's responsibility is containing logic to access to which data source. Please move the state to ViewModel and perform update the state itself there

@hieuwu
Copy link
Collaborator

hieuwu commented Oct 23, 2023

And also when I launch app I see the text displays null? Could you please also take a look?
Screenshot 2023-10-23 at 19 52 23

import space.taran.arkmemo.models.TextNote
import space.taran.arkmemo.preferences.MemoPreferences
import javax.inject.Inject

@HiltViewModel
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please do me a favor. If you have time, it would be nice if you can move all view models to ui package. ViewModel is a part of the presentation layer and it controls the state to be displayed in the screen. It does not belong to data layer

@shubertm shubertm temporarily deployed to Development October 23, 2023 13:20 — with GitHub Actions Inactive
@shubertm
Copy link
Member Author

And also when I launch app I see the text displays null? Could you please also take a look?
Screenshot 2023-10-23 at 19 52 23

I think that's because we read time from file metadata. So when its newly saved the metadata is null, metadata is not yet read from file and we can't read it either.

@shubertm shubertm temporarily deployed to Development October 25, 2023 06:57 — with GitHub Actions Inactive
@shubertm shubertm requested review from kirillt and hieuwu October 25, 2023 07:04
@hieuwu
Copy link
Collaborator

hieuwu commented Oct 25, 2023

Looks fine for now. Assuming that the new code works properly. I will work with you to refactor this project to make the architecture aligned with latest best practices

@shubertm
Copy link
Member Author

Looks fine for now. Assuming that the new code works properly. I will work with you to refactor this project to make the architecture aligned with latest best practices

That will be amazing

@shubertm shubertm merged commit 1c94c60 into main Oct 25, 2023
1 check passed
@kirillt kirillt deleted the user-metadata branch December 16, 2023 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants