ecency / ecency-mobile

Ecency Mobile - reimagined social blogging, contribute and get rewarded (for Android and iOS)
https://ecency.com
MIT License
232 stars 69 forks source link

[BUG] Problems at initial setup #1842

Open albixh opened 3 years ago

albixh commented 3 years ago

Describe the bug A multitude of problems occur when setting up the project on a new development machine. States that are initialized as an empty array are actually undefined on certain occasions. An example for this would be the "reblogs" state in postCardContainer.js which is undefined at startup. Furthermore, when trying to login using credentials, getPrivateKeys in auth.js returns undefined keys.

To Reproduce Steps to reproduce the behavior:

  1. Build the project on a new machine.
  2. Start the application (should break on startup because reblogs is undefined)
  3. If the error on step 2 is skipped, login using username and password (should throw intl error because key is undefined)

Expected behavior States and keys should not be undefined.

Screenshots or Video If applicable, add screenshots to help explain your problem.

Undefined reblogs example: Screenshot_1611927932

Login example: Screenshot_1611928219

Smartphone (please complete the following information): Tested on different simulators for both Android and iOS.

Additional context A workaround for the undefined state would be to use nullish coalescing operator when passing the state to a view. For reblogs it would look like this: reblogs={reblogs ?? []}

While this ensures that no undefined values are passed to the view, this is not a clean solution since the field is still undefined in the data-layer. A better solution would be combining the function updater form with object spread syntax to merge update objects: getPostReblogs(_content).then((result) => { setReblogs(prevState => ({ ...prevState, ...result })); });

This fixes the issues for me, I'm still wondering though if I am missing something at the initial setup of the project since you are not using any of the mentioned solutions and the App is published on Android and iOS without any problems.

feruzm commented 3 years ago

Main problem is likely absent of .env file (environment variables) which includes our internal api to get reblogs. So to get rid of this problem in your initial setup or fork, you would need to modify getPostReblogs function and return empty array always or replace with your own api that returns exact same formatted data.

albixh commented 3 years ago

That is what I figured, I suppose the problems at login are also being caused because it is dependent on your internal library? Else I don't see a way someone can actively support this project since most of the issue tickets require the user to be logged in to access the feature referenced by the issue.

feruzm commented 3 years ago

As I mentioned, you can disable those API, if you want to fork the project. If you want to submit PR, you can still do so by disabling or adding empty array into our internal APIs. Login also does Point related operation which means, you will have to comment out that line in code. There is .env.example file that should be renamed to .env and filled with proper API fields if doesn't exist, can be commented out from source code. What are you planning to do, perhaps with more details, I can give more directions and see what needs to be changed in Readme?

feruzm commented 3 years ago

Issues related to our internal APIs on this repo, we will fix it ourselves and those are mostly for referencing tickets for our internal work/priority management.

feruzm commented 3 years ago

Screenshot related to words issue with translation files, are you using latest development branch?

albixh commented 3 years ago

I was planning on implementing this feature request: https://github.com/ecency/ecency-mobile/issues/752 The feed requires a login to become available, but I figure since this feature is related to your api you might not want others implementing it. But even if you look at this one: https://github.com/ecency/ecency-mobile/issues/1805 It only requires front end changes but you still need to login for the draft to become available. Commenting out multiple lines of code just to start contributing doesn't feel too sensible to me.

Screenshot related to words issue with translation files, are you using latest development branch?

Yes, I am using the latest dev branch. The issue is triggered because getPrivateKeys() from auth.js returns empty keys.

feruzm commented 3 years ago

752 is possible to implement without .env variables... all you need to do is to return empty results from API providers in src/providers/ecency/ files.

1805 unfortunately requires work with drafts, although api is already there, just need UI selection and looping over api calls or add new api with support for multiple deletes.

We will prepare sandboxed APIs for development perhaps, we want others to be able to contribute easily. So solution is to offer sandboxed API or document more API endpoints so any developer can get started.