-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
shubertm
commented
Sep 28, 2023
•
edited by kirillt
Loading
edited by kirillt
- Separate user-defined properties into dedicated storage #8
We have small bug here. Steps to reproduce:
|
The bug with disappearing notes is fixed now. I've updated ark-filepicker dependency to take it from GitHub Packages. |
Feel free to merge as soon as @hieuwu puts a green tick. |
Alright |
app/src/main/java/space/taran/arkmemo/data/repositories/TextNotesRepo.kt
Outdated
Show resolved
Hide resolved
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 |
app/src/main/java/space/taran/arkmemo/data/repositories/TextNotesRepo.kt
Outdated
Show resolved
Hide resolved
} catch (e: Exception) { | ||
e.printStackTrace() | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
} catch (e: Exception) { | ||
e.printStackTrace() | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
app/src/main/java/space/taran/arkmemo/data/repositories/TextNotesRepo.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/space/taran/arkmemo/data/repositories/TextNotesRepo.kt
Show resolved
Hide resolved
} catch (e: Exception) { | ||
e.printStackTrace() | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :)
private val _textNotes = MutableStateFlow(listOf<TextNote>()) | ||
val textNotes: StateFlow<List<TextNote>> = _textNotes |
There was a problem hiding this comment.
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
import space.taran.arkmemo.models.TextNote | ||
import space.taran.arkmemo.preferences.MemoPreferences | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel |
There was a problem hiding this comment.
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
…tesRepo.kt Co-authored-by: Hieu Vu <[email protected]>
…tesRepo.kt Co-authored-by: Hieu Vu <[email protected]>
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 |