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

Rewrite apollo integration #62

Merged
merged 104 commits into from Jan 9, 2020
Merged
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
4362a26
bring in apollo example
icco Dec 25, 2019
f0e7065
progress
icco Dec 25, 2019
ba0ab8d
more
icco Dec 25, 2019
910291f
lint
icco Dec 25, 2019
c09d1b7
sure
icco Dec 25, 2019
b0085a6
prog
icco Dec 25, 2019
751ae2b
lint
icco Dec 25, 2019
ab0f8ee
clean up imports
icco Dec 25, 2019
57cc42f
Merge branch 'master' into rewrite-apollo
icco Dec 26, 2019
13c9c7e
sitemap.xml
icco Dec 26, 2019
120acd0
Revert "sitemap.xml"
icco Dec 26, 2019
a51c6d7
tweak some pages
icco Dec 27, 2019
5d8ef9f
lint
icco Dec 27, 2019
0079f21
inprogress
icco Dec 27, 2019
7db7c45
move to apollo hooks
icco Dec 27, 2019
9450577
lint
icco Dec 27, 2019
8204c8c
tweak apollo lib
icco Dec 27, 2019
9dff145
update documet
icco Dec 27, 2019
783f2b9
lint
icco Dec 27, 2019
6c51b97
clean bavbel
icco Dec 27, 2019
1a7a0a6
rewrite header
icco Dec 27, 2019
86b54f2
tweak index
icco Dec 27, 2019
f959bab
tweaks that do nothing
icco Dec 27, 2019
48a9a61
bring overcomponents from rewrite-apollo
icco Dec 27, 2019
9978e68
lcean uop
icco Dec 27, 2019
36998a4
doesn't help
icco Dec 28, 2019
b8ed2c9
did nothing
icco Dec 28, 2019
0711057
lint
icco Dec 28, 2019
22b7db7
simplify app.js
icco Jan 3, 2020
fa437ee
delete _app
icco Jan 3, 2020
1bc9e01
add react-hooks
icco Jan 3, 2020
cf71d23
fix has more
icco Jan 3, 2020
89e51eb
Merge branch 'rewrite-apollo' into smaller-apl
icco Jan 3, 2020
0c1a1af
Merge pull request #63 from icco/smaller-apl
icco Jan 3, 2020
7e6decc
fixes errors
icco Jan 3, 2020
c00cd4e
Fix post
icco Jan 3, 2020
cee19c0
lint
icco Jan 3, 2020
c1a468b
fix tag page
icco Jan 3, 2020
9696a23
fix commenteditor
icco Jan 3, 2020
d802ff8
lint
icco Jan 3, 2020
8c7461c
clean up package
icco Jan 3, 2020
8da14b6
admin progress
icco Jan 3, 2020
d2bde20
lint
icco Jan 3, 2020
f958c7a
fix type bug
icco Jan 3, 2020
427733e
add apollo
icco Jan 3, 2020
806c922
mv withError to _error
icco Jan 3, 2020
90ac770
remove witherror
icco Jan 3, 2020
4b05c50
lint
icco Jan 3, 2020
8529ed2
hardcode draft list to < 20
icco Jan 3, 2020
76b1e20
add import
icco Jan 3, 2020
c46458f
fix 404 and lint
icco Jan 3, 2020
86a9ba3
untested striping
icco Jan 3, 2020
b418c0b
lint
icco Jan 3, 2020
4494844
Allow for dev csp
icco Jan 3, 2020
1dd21c2
progress
icco Jan 3, 2020
6323b6e
lint
icco Jan 3, 2020
9f0b65e
nope
icco Jan 3, 2020
0be49de
don't require react
icco Jan 3, 2020
6bca0c7
ah ha
icco Jan 4, 2020
52eece1
lint
icco Jan 4, 2020
c1e176d
fix editpost
icco Jan 4, 2020
1f4e4d1
fix some deps
icco Jan 4, 2020
4d4efa4
remove unused packages
icco Jan 4, 2020
a3a427a
add depcheck to lint
icco Jan 4, 2020
1647ae8
upgrade
icco Jan 4, 2020
c803380
yarn maintain
icco Jan 4, 2020
3db9069
starting down rewrite auth0 path
icco Jan 4, 2020
9694ee7
sure
icco Jan 4, 2020
7094ffc
lint
icco Jan 4, 2020
6221a0d
changes re auth
icco Jan 5, 2020
ad895a3
fix ssr
icco Jan 5, 2020
8f17508
move window logic to auth
icco Jan 5, 2020
064c1e6
lint
icco Jan 5, 2020
4915197
some progress
icco Jan 5, 2020
3ea09b4
better oops
icco Jan 5, 2020
bc2651e
lint
icco Jan 5, 2020
90718e7
cleanup react-svg
icco Jan 5, 2020
e886963
fuck I don't know
icco Jan 5, 2020
ccd0f62
lint config
icco Jan 5, 2020
8b291e7
better lint config
icco Jan 5, 2020
25e9a51
lint
icco Jan 5, 2020
3af55e6
lint fixes
icco Jan 5, 2020
5c76477
tweaks
icco Jan 5, 2020
2f68c7d
progess
icco Jan 5, 2020
c3284e0
nt
icco Jan 5, 2020
3c8a5f1
sure
icco Jan 5, 2020
39b8082
build at end of lint
icco Jan 5, 2020
8d1dad7
refactor
icco Jan 5, 2020
d2c3986
lint
icco Jan 5, 2020
99dc87e
update components
icco Jan 5, 2020
05c3910
doesn't work don't know why
icco Jan 5, 2020
7a267c1
lint
icco Jan 5, 2020
b30ec6b
nothing works
icco Jan 5, 2020
ec2c863
Merge remote-tracking branch 'origin/master' into rewrite-apollo
icco Jan 9, 2020
e4e60df
sure for now
icco Jan 9, 2020
c9159e2
cleanup
icco Jan 9, 2020
d7933ed
new auth token, call your friends
icco Jan 9, 2020
636bcd7
lots of progress
icco Jan 9, 2020
1e55d78
fix permissions
icco Jan 9, 2020
9522e6e
fix import paths
icco Jan 9, 2020
683777a
fix post lists
icco Jan 9, 2020
42004b5
fix comment auth
icco Jan 9, 2020
8e15ed0
lint
icco Jan 9, 2020
9f36c20
remove unused
icco Jan 9, 2020
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1,6 +1,4 @@
const env = require("./env-config.js");

module.exports = {
presets: ["next/babel"],
plugins: [["transform-define", env]],
plugins: ["graphql-tag"],
};
@@ -0,0 +1,32 @@
module.exports = {
env: {
browser: true,
es6: true,
},
extends: ["eslint:recommended", "plugin:react/recommended"],
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
React: "writable",
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: "module",
},
plugins: ["react", "prettier", "react-hooks"],
rules: {
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"prettier/prettier": "error",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
},
settings: {
react: {
version: "detect",
},
},
};

This file was deleted.

@@ -5,6 +5,7 @@ EXPOSE 8080
ENV NODE_ENV=production
ENV GRAPHQL_ORIGIN="https://graphql.natwelch.com/graphql"
ENV PORT=8080
ENV DOMAIN="https://writing.natwelch.com"

RUN apk add --no-cache git

This file was deleted.

This file was deleted.

@@ -1,57 +1,12 @@
import { graphql } from "react-apollo";
import gql from "graphql-tag";
import Link from "next/link";
import InfiniteScroll from "react-infinite-scroller";
import gql from "graphql-tag";
import { ErrorMessage, Loading } from "@icco/react-common";
import { NetworkStatus } from "apollo-client";
import { useQuery } from "@apollo/react-hooks";

import Datetime from "./Datetime";

function AdminLinkList({ data: { error, links, loadMore } }) {
if (error) {
return <ErrorMessage message="Error loading links." />;
}

if (links && links.length) {
return (
<section className="pa3 mw8 center">
<InfiniteScroll
threshold={500}
loadMore={loadMore}
hasMore={true}
loader={<Loading key="link-loader" />}
>
<ul className="list pl0" key="link-ul">
{links.map(l => (
<li className="mv3" key={"link-" + l.id}>
<span className="mr3">
<Datetime>{l.created}</Datetime>
</span>
<a href={l.uri} className="link dark-blue dim">
{l.title}
</a>
{" - "}
<span
className="gray link pointer dim"
onClick={() => {
let text = `[${l.title} - ${l.description}](${l.uri})`;
navigator.clipboard.writeText(text);
}}
>
{l.uri}
</span>
<blockquote>{l.description}</blockquote>
</li>
))}
</ul>
</InfiniteScroll>
</section>
);
}

return <div />;
}

export const SomeLinks = gql`
export const linksQuery = gql`
query links($offset: Int!, $perpage: Int!) {
links(input: { limit: $perpage, offset: $offset }) {
id
@@ -63,31 +18,84 @@ export const SomeLinks = gql`
}
`;

const PER_PAGE = 50;
export const PER_PAGE = 50;

let hasMoreLinks = true;
export default function AdminLinkList() {
const { loading, error, data, fetchMore, networkStatus } = useQuery(
linksQuery,
{
variables: {
offset: 0,
perpage: PER_PAGE,
},
notifyOnNetworkStatusChange: true,
fetchPolicy: "cache-and-network",
}
);

const loadingMoreLinks = networkStatus === NetworkStatus.fetchMore;

export default graphql(SomeLinks, {
options: {
variables: {
offset: 0,
perpage: PER_PAGE,
},
},
props: ({ data }) => ({
data: {
...data,
loadMore: page => {
var offset = page * PER_PAGE;
return data.fetchMore({
variables: { offset, perpage: PER_PAGE },
updateQuery: (previousResult = {}, { fetchMoreResult = {} }) => {
var previouslinks = previousResult.links;
var currentlinks = fetchMoreResult.links;
return {
links: [...previouslinks, ...currentlinks],
};
},
const loadMoreLinks = page => {
fetchMore({
variables: {
offset: page * PER_PAGE,
},
updateQuery: (previousResult, { fetchMoreResult }) => {
if (!fetchMoreResult) {
return previousResult;
}
if (fetchMoreResult.links.length <= 0) {
hasMoreLinks = false;
return previousResult;
}
return Object.assign({}, previousResult, {
// Append the new links results to the old one
links: [...previousResult.links, ...fetchMoreResult.links],
});
},
},
}),
})(AdminLinkList);
});
};

if (error) {
return <ErrorMessage message="Error loading links." />;
}
if (loading && !loadingMoreLinks) return <Loading key={0} />;

const { links } = data;

return (
<section className="pa3 mw8 center">
<InfiniteScroll
threshold={500}
loadMore={loadMoreLinks}
hasMore={hasMoreLinks}
loader={<Loading key="link-loader" />}
>
<ul className="list pl0" key="link-ul">
{links.map(l => (
<li className="mv3" key={"link-" + l.id}>
<span className="mr3">
<Datetime>{l.created}</Datetime>
</span>
<a href={l.uri} className="link dark-blue dim">
{l.title}
</a>
{" - "}
<span
className="gray link pointer dim"
onClick={() => {
let text = `[${l.title} - ${l.description}](${l.uri})`;
navigator.clipboard.writeText(text);
}}
>
{l.uri}
</span>
<blockquote>{l.description}</blockquote>
</li>
))}
</ul>
</InfiniteScroll>
</section>
);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.