Introduce stale while revalidate pattern (#1555)

This Improves the frontend performance with stale while
revalidate pattern.

There are noticeable performance problems in the frontend that
needed addressing. While implementing the stale-while-revalidate
pattern to display cached responses while re-fetching up-to-date
data in the background, in the same vein we used the opportunity
to remove legacy code involving redux as much as possible,
cleaned up many components and converted them to functional
react components.

Co-authored-by: Sebastian Sdorra <sebastian.sdorra@cloudogu.com>
Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
Konstantin Schaper
2021-02-24 08:17:40 +01:00
committed by GitHub
parent ad5c8102c0
commit 3a8d031ed5
243 changed files with 150259 additions and 80227 deletions

View File

@@ -25,16 +25,15 @@
import React, { FC } from "react";
import { useTranslation } from "react-i18next";
import Notification from "../Notification";
import { Me } from "@scm-manager/ui-types";
import { connect } from "react-redux";
import { useMe } from "@scm-manager/ui-api";
type Props = {
// props from global state
me: Me;
};
const CommitAuthor: FC<Props> = ({ me }) => {
const CommitAuthor: FC = () => {
const [t] = useTranslation("repos");
const { data: me } = useMe();
if (!me) {
return null;
}
const mail = me.mail ? me.mail : me.fallbackMail;
@@ -48,13 +47,4 @@ const CommitAuthor: FC<Props> = ({ me }) => {
);
};
const mapStateToProps = (state: any) => {
const { auth } = state;
const me = auth.me;
return {
me
};
};
export default connect(mapStateToProps)(CommitAuthor);
export default CommitAuthor;

View File

@@ -22,7 +22,7 @@
* SOFTWARE.
*/
import React from "react";
import { apiClient } from "../apiclient";
import { apiClient, NotFoundError } from "@scm-manager/ui-api";
import ErrorNotification from "../ErrorNotification";
// @ts-ignore
import parser from "gitdiff-parser";
@@ -30,7 +30,6 @@ import parser from "gitdiff-parser";
import Loading from "../Loading";
import Diff from "./Diff";
import { DiffObjectProps, File } from "./DiffTypes";
import { NotFoundError } from "../errors";
import { Notification } from "../index";
import { withTranslation, WithTranslation } from "react-i18next";

View File

@@ -22,7 +22,7 @@
* SOFTWARE.
*/
import React from "react";
import { Changeset, Collection, Link } from "@scm-manager/ui-types";
import { Changeset, HalRepresentation, Link } from "@scm-manager/ui-types";
import LoadingDiff from "../LoadingDiff";
import Notification from "../../Notification";
import { WithTranslation, withTranslation } from "react-i18next";
@@ -34,11 +34,11 @@ type Props = WithTranslation & {
fileControlFactory?: FileControlFactory;
};
export const isDiffSupported = (changeset: Collection) => {
export const isDiffSupported = (changeset: HalRepresentation) => {
return !!changeset._links.diff || !!changeset._links.diffParsed;
};
export const createUrl = (changeset: Collection) => {
export const createUrl = (changeset: HalRepresentation) => {
if (changeset._links.diffParsed) {
return (changeset._links.diffParsed as Link).href;
} else if (changeset._links.diff) {