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

Client side templates 3 #1216

Merged
merged 47 commits into from
Jan 26, 2021
Merged

Client side templates 3 #1216

merged 47 commits into from
Jan 26, 2021

Conversation

jtojnar
Copy link
Member

@jtojnar jtojnar commented Sep 5, 2020

This is the last one. After this, we can start moving setting event handlers in jQuery onto the respective components and then finally switch to react or something.

Depends on #1215
Fixes #928

@jtojnar jtojnar added this to the 2.19 milestone Sep 5, 2020
@jtojnar jtojnar marked this pull request as draft September 5, 2020 15:23
@jtojnar jtojnar force-pushed the client-side-templates-3 branch 4 times, most recently from 208534d to 2717992 Compare September 12, 2020 16:29
@jtojnar

This comment has been minimized.

@jtojnar jtojnar force-pushed the client-side-templates-3 branch 2 times, most recently from b05779b to b3d8dd0 Compare September 12, 2020 16:57
@jtojnar jtojnar marked this pull request as ready for review September 12, 2020 23:05
@jtojnar
Copy link
Member Author

jtojnar commented Sep 13, 2020

I managed to reproduce the incompatibility in IndexedDB schema when upgrading:

Unhandled rejection: TypeError: item.icon is undefined

And logging out does not seem to be sufficient because selfoss.db.storage is set to null on failure so the logout cannot clear it:

https://github.com/SSilence/selfoss/blob/7bacaab321d48813777934ac129a0db1d81c5c64/assets/js/selfoss-events-navigation.js#L237

@jtojnar
Copy link
Member Author

jtojnar commented Sep 13, 2020

And looks like GCEntries is another place that expects storage to be present but it is cleared before running it:

https://github.com/SSilence/selfoss/blob/7bacaab321d48813777934ac129a0db1d81c5c64/assets/js/selfoss-db.js#L324-L330

@jtojnar
Copy link
Member Author

jtojnar commented Dec 6, 2020

The clearing of selfoss.db.storage should be fixed now.

I also fixed ServiceWorker not being registered, which I broke in 16f1cd6 and sync event handler after update that I missed in dd8d428.

@jtojnar jtojnar force-pushed the client-side-templates-3 branch 4 times, most recently from 2918662 to 9ec030a Compare December 10, 2020 14:54
@jtojnar jtojnar force-pushed the client-side-templates-3 branch 2 times, most recently from 633550f to 539ffed Compare December 17, 2020 11:06
@jtojnar
Copy link
Member Author

jtojnar commented Jan 4, 2021

I just finished porting the tag menu in the sidebar to real React – no more mutating its DOM with jQuery. We now have two JSX libraries React + react-dom here, and jsx-dom in all other templates. The latter is still used so that we can create DOM elements using JSX instead of string templating and $(html)/element.innerHTML.

I would like to get rid of DOM mutations eventually and use React everywhere but we are currently mutating the DOM all over the place. Fortunately, the conversion can be done piecemeal as demonstrated in client: Use real React for NavTags commit.

We cannot really pass new data to the components when we process HTTP responses so we need to create EventTarget objects and pass them to the components so that the components can add event listeners and we can pass them changed data through dispatching events.

In preparation for removing the entire Navigation bar.
This one is little uglier since I need a way of passing errors to the form.
I decided to do that by wrapping the form in a stateful component
and setting the error through its method.
Had to disable react/no-render-return-value because we rely on it and React still uses sync rendering.
This is almost full port of Settings/Sources page to React.

jQuery is now only used there for fadeout animation of elements that will be removed from DOM.
It is nightmare trying to edit all three objects at the same time.

No changes were made other than the split and import wrangling.
I made the change to returning the original promise in 35de644 but that makes no sense. The error handler is already re-throwing the error so `then`s would not fire if that happened and `catch`es would fire too. The only thing this does is trigger an unhandled promise rejection from the rethrown error.

Let’s revert the change and also use Promise.reject instead of throwing since throwing seems to confuse Firefox’s debugger sometimes.
It has not been used since the the switch to seek pagination.
Move filtering completely to filter method.
Building the entries UI in a single place (db) will make it easier to create it with React.
Also use tinykeys so that we can reduce jQuery usage.
This will allow us to drive navigation using routes, greatly simplifying the control flow.
It will also allow us to implement long requested features like having an URL for adding sources or searching easily.

In fact search term is now part of URL.

Also the mark all as read button is now disabled on the sources page.
We changed it to link on desktop for better coverage but forgot to do it on mobile,
breaking it. Let’s remedy this now.
As per react docs:

> We recommend using the exhaustive-deps rule as part of our eslint-plugin-react-hooks package. It warns when dependencies are specified incorrectly and suggests a fix.
We should just remove the old list while the new one is loading to make the interface cleaner.
Also clearing a selected item is necessary to avoid navigation using shortcuts not working after switching to a different tag since the ui functions assume the selected item exists.
@jtojnar jtojnar reopened this Jan 26, 2021
@jtojnar
Copy link
Member Author

jtojnar commented Jan 26, 2021

Rebased and will merge once CI passes.

@jtojnar jtojnar merged commit b98a3b4 into master Jan 26, 2021
@jtojnar jtojnar deleted the client-side-templates-3 branch January 26, 2021 09:13
@jtojnar jtojnar mentioned this pull request Jul 21, 2022
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.

Switch to client-side templating
1 participant