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

Qu embed #1756

Draft
wants to merge 57 commits into
base: react
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ca593b7
chore(deps): [security] bump socket.io-parser from 3.3.0 to 3.3.2 (#1…
dependabot-preview[bot] Jul 1, 2021
39808bb
chore(deps): [security] bump postcss from 7.0.32 to 7.0.36 (#1200)
dependabot-preview[bot] Jul 1, 2021
24039d4
chore(deps): [security] bump hosted-git-info from 2.8.8 to 2.8.9 (#1190)
dependabot-preview[bot] Jul 1, 2021
62040aa
chore(deps): [security] bump underscore from 1.11.0 to 1.13.1 (#1189)
dependabot-preview[bot] Jul 1, 2021
b1905b1
chore(deps): [security] bump ssri from 6.0.1 to 6.0.2 (#1183)
dependabot-preview[bot] Jul 1, 2021
5d06acc
chore(deps): [security] bump y18n from 4.0.0 to 4.0.3 (#1176)
dependabot-preview[bot] Jul 1, 2021
60e2db1
chore(deps): [security] bump ini from 1.3.5 to 1.3.8 (#1134)
dependabot-preview[bot] Jul 1, 2021
b7b076e
chore(deps): [security] bump socket.io from 2.3.0 to 2.4.1 (#1145)
dependabot-preview[bot] Jul 1, 2021
571c7f1
chore(deps): [security] bump elliptic from 6.5.3 to 6.5.4 (#1164)
dependabot-preview[bot] Jul 1, 2021
5ae9eeb
Upgrade to GitHub-native Dependabot (#1185)
dependabot-preview[bot] Jul 1, 2021
50486b2
ci: revert versioning strategy to increase
wopian Jul 1, 2021
076b443
Configure dependabot to update react stuff
NuckChorris Aug 22, 2021
c994b77
Tag the new react bumps with a label
NuckChorris Aug 22, 2021
5058422
Add prettierrc.json
NuckChorris Jun 30, 2021
7ad0539
Fix naive imgix url utility
NuckChorris Sep 21, 2021
72d2dd3
Renamed "Personal Notes" to "Notes" to avoid confusion. (#1607)
Uricorn Jan 2, 2022
e2d0d8d
add sign in/up/out functionality without much styling
toyhammered Feb 28, 2022
f108bf7
Fix upvoted indication reactions in dark theme (#1785)
Reinachan Apr 23, 2022
14f247e
Adds granular control for NSFW content (#1815)
Reinachan May 3, 2022
1020ec8
ci: remove wopian as assignee
wopian Jun 8, 2022
291e19c
Refactor Algolia service
NuckChorris Jun 18, 2022
9719c42
Switch favorites to use Algolia search
NuckChorris Jun 18, 2022
c1ab603
Get rid of ember dependabot updates
NuckChorris Jun 30, 2022
205825d
Fixes the full-page posts overflow bug in Chrome and Safari (#1901)
Reinachan Jul 16, 2022
9bff9f7
Fix algolia.getIndex task concurrency
NuckChorris Jul 22, 2022
5d920a6
Merge branch 'the-future' into qu-embed
toyhammered Jan 18, 2023
70e1732
wip
toyhammered Feb 6, 2023
a981a80
basic functionality with search
toyhammered Feb 8, 2023
62f9447
Merge branch 'react' into qu-embed
toyhammered Feb 8, 2023
d4043f7
accidentally deleted?
toyhammered Feb 8, 2023
6b286aa
fix everything broken due to update
toyhammered Feb 8, 2023
76d7a82
functional selection
toyhammered Feb 17, 2023
c6ba252
grab additional fields
toyhammered Feb 17, 2023
d8eb887
ability to save new records to indexDB dynamically
toyhammered Feb 20, 2023
88cd640
basic logic to show submit button
toyhammered Feb 22, 2023
6d7f1e3
No nodes means missing data
toyhammered Feb 22, 2023
2971e48
add search split between what is in your library and new
toyhammered Feb 22, 2023
f3c9ea8
include id
toyhammered Feb 23, 2023
b2ca02b
change htings to stage environment for easier testing
toyhammered Feb 25, 2023
7f6a0e1
quick update for progress and post
toyhammered Feb 25, 2023
dcb46e7
add ability to post + update library entry
toyhammered Feb 27, 2023
9af335b
temp delete index
toyhammered Mar 2, 2023
8a8c920
revert to using prod again
toyhammered Mar 2, 2023
c904da9
add kitsu direct url link
toyhammered Mar 2, 2023
c232985
remove unused import
toyhammered Mar 2, 2023
a87bcb5
more small stuff
toyhammered Mar 2, 2023
97971a0
some moving around
toyhammered Mar 3, 2023
ef7d452
hack for converting MediaTypeEnum
toyhammered Mar 5, 2023
95eb48b
add anime support
toyhammered Mar 6, 2023
16589eb
wip refactor
toyhammered Mar 6, 2023
2f847a9
back to original state
toyhammered Mar 7, 2023
62bae48
fix unlinking. Add active tabs
toyhammered Mar 10, 2023
1934c4c
adding some styling
toyhammered Mar 12, 2023
6eec7cb
add chosenMedia stylings
toyhammered Mar 14, 2023
f6732b0
fix up some styling a bit
toyhammered Apr 4, 2023
983c225
Merge branch 'react' into qu-embed
toyhammered Jun 11, 2024
51c4264
small fixes
toyhammered Jun 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
VITE_API_HOST=https://kitsu.io/
# VITE_API_HOST=https://staging.kitsu.io/
VITE_CLIENT_ID=it_PexBnH20XBIwTrIPTFX74ZdLHibtYBK7uDdAtznI
VITE_MAL_CLIENT_ID=d4452b64fc5fc36c1a9f8785b63d44df
1 change: 1 addition & 0 deletions apollo.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
client: {
service: {
name: 'kitsu',
// url: 'https://staging.kitsu.io/api/graphql',
url: 'https://kitsu.io/api/graphql',
},
},
Expand Down
36,838 changes: 9,492 additions & 27,346 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"date-fns": "^2.28.0",
"graphql": "^16.8.1",
"graphql-scalars": "^1.14.1",
"idb": "^7.1.1",
"lodash-es": "^4.17.21",
"preferred-locale": "^1.0.10",
"react": "^18.0.0",
Expand Down
32 changes: 32 additions & 0 deletions src/QUEmbedApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { Suspense } from 'react';

import 'app/initializers';
import 'app/styles/index.css';

import QURouter from 'app/QURouter';
import Header from 'app/components/QUEmbed/Header';
import { AccountContextProvider } from 'app/contexts/AccountContext';
import IntlProvider from 'app/contexts/IntlContext';
import { SessionContextProvider } from 'app/contexts/SessionContext';
import UrqlContextProvider from 'app/contexts/UrqlContext';

const QUEmbedApp: React.FC = function ({ children = <QURouter /> }) {
return (
<React.StrictMode>
<Suspense fallback={null}>
<SessionContextProvider>
<UrqlContextProvider>
<IntlProvider>
<AccountContextProvider>
<Header />
{children}
</AccountContextProvider>
</IntlProvider>
</UrqlContextProvider>
</SessionContextProvider>
</Suspense>
</React.StrictMode>
);
};

export default QUEmbedApp;
46 changes: 46 additions & 0 deletions src/QURouter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import { Route, Routes } from 'react-router-dom';

import ForgotPasswordModal from './pages/Auth/ForgotPassword';
// import 'app/styles/index.css';

// import NotFoundPage from './pages/Errors/NotFound';
import AuthLayout from './pages/Auth/Layout';
import SignInModal from './pages/Auth/SignIn';
import SignUpModal from './pages/Auth/SignUp';

import HomePage from './pages/QUEmbed/Home';
import MediaPage from './pages/QUEmbed/MediaPage';
import SearchPage from './pages/QUEmbed/SearchPage';
import { UserRoute } from './utils/user_route';

export default function QURouter() {
return (
<>
<Routes>
<Route path="auth" element={<AuthLayout displayMode="modal" />}>
<Route path="sign-in" element={<SignInModal />} />
<Route path="sign-up" element={<SignUpModal />} />
<Route path="forgot-password" element={<ForgotPasswordModal />} />
</Route>
{/* NOTE: is there a way to declare which query params are allowed? */}
<Route
path="/search"
element={
<UserRoute>
<SearchPage />
</UserRoute>
}
/>
<Route
path="/"
element={
<UserRoute>
<MediaPage />
</UserRoute>
}
/>
</Routes>
</>
);
}
36 changes: 36 additions & 0 deletions src/components/QUEmbed/ChosenMedia/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { ReactElement } from 'react';

import { ActiveTabs } from 'app/pages/QUEmbed/MediaPage';

import styles from './styles.module.css';

interface Props {
onClickUnlink: (e: any) => void;
onClickActiveTab: (tab: ActiveTabs) => void;
}

export default function ChosenMediaHeader({
onClickUnlink,
onClickActiveTab,
}: Props): ReactElement {
return (
<nav className={styles.headers}>
<li
className={styles.chosenMedia}
onClick={() => onClickActiveTab('media')}>
{'Media'}
</li>
<li
className={styles.reaction}
onClick={() => onClickActiveTab('reaction')}>
{'Reaction'}
</li>
<li className={styles.rating} onClick={() => onClickActiveTab('rating')}>
{'Rating'}
</li>
<li className={styles.unlink}>
<button onClick={onClickUnlink}>{'Unlink'}</button>
</li>
</nav>
);
}
25 changes: 25 additions & 0 deletions src/components/QUEmbed/ChosenMedia/Header/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.headers {
display: grid;
grid-template-columns: 1fr 1fr 1fr 0.5fr;
grid-template-rows: 1fr;
gap: 0px 0px;
grid-template-areas:
"chosenMedia reaction rating unlink";
grid-area: headers;
}

.chosenMedia {
grid-area: chosenMedia;
}

.reaction {
grid-area: reaction;
}

.rating {
grid-area: rating;
}

.unlink {
grid-area: unlink;
}
136 changes: 136 additions & 0 deletions src/components/QUEmbed/ChosenMedia/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import React, { ReactElement } from 'react';

import BannerImage from 'app/components/content/BannerImage';
import ImageSource from 'app/components/content/Image';
import {
LibraryEntryUpdateProgressByMediaInput,
PostCreateInput,
} from 'app/graphql/types';
import { formattedMediaType } from 'app/pages/QUEmbed/MediaPage';

import { MediaDataFragment } from '../findMediaByIdAndType-gql';
import { useQuickUpdateMutation } from './quickUpdate-gql';
import { useQuickUpdateNoPostMutation } from './quickUpdateNoPost-gql';
import styles from './styles.module.css';

interface QUEmbedProps {
record: MediaDataFragment;
}

export default function ChosenMedia({ record }: QUEmbedProps): ReactElement {
const unitType = record.myLibraryEntry?.nextUnit?.__typename;
const unitPrefix = unitType === 'Episode' ? 'Watching' : 'Reading';
const [unitId, setUnitId] = React.useState<string | undefined>(
record.myLibraryEntry?.nextUnit?.id
);
const [unitNumber, setUnitNumber] = React.useState<number>(
record.myLibraryEntry?.nextUnit?.number || 1
);

const [post, setPost] = React.useState<string>('');
const kitsuUrl = `https://kitsu.io/${record.type.toLowerCase()}/${
record.slug
}`;
const background = record.bannerImage as ImageSource;

const [, createQuickUpdate] = useQuickUpdateMutation();
const [, createQuickUpdateNoPost] = useQuickUpdateNoPostMutation();

const handleSubmit = (e) => {
e.preventDefault();

console.log('progress', unitNumber);
console.log('post', post);

const libraryEntryInput: LibraryEntryUpdateProgressByMediaInput = {
mediaId: record.id,
mediaType: formattedMediaType(record.type),
progress: unitNumber,
};

if (post === '' || post === null) {
const request = createQuickUpdateNoPost({
libraryEntryInput,
});

request.then((res) => {
if (res.data?.libraryEntry?.updateProgressByMedia?.errors) {
console.log('Error updating Library Entry Progress', res);
} else {
console.log('Success', res);
setUnitId(
res.data?.libraryEntry?.updateProgressByMedia?.libraryEntry
?.nextUnit?.id
);
setUnitNumber(
res.data?.libraryEntry?.updateProgressByMedia?.libraryEntry
?.nextUnit?.number || unitNumber + 1
);
setPost('');
}
});
} else {
const sfw = record.sfw;
const postInput: PostCreateInput = {
content: post,
mediaId: record.id,
mediaType: formattedMediaType(record.type),
isSpoiler: true,
isNsfw: !sfw,
spoiledUnitId: unitId,
spoiledUnitType: unitType,
};

const request = createQuickUpdate({
libraryEntryInput,
postInput,
});

request.then((res) => {
if (res.data?.libraryEntry?.updateProgressByMedia?.errors) {
console.log('Error updating Library Entry Progress', res);
} else if (res.data?.post?.create?.errors) {
console.log('Error creating Post', res);
} else {
console.log('Success', res);
setUnitId(
res.data?.libraryEntry?.updateProgressByMedia?.libraryEntry
?.nextUnit?.id
);
setUnitNumber(
res.data?.libraryEntry?.updateProgressByMedia?.libraryEntry
?.nextUnit?.number || unitNumber + 1
);
setPost('');
}
});
}
};

return (
<>
<div className={styles.banner}>
<BannerImage className={styles.mainImage} background={background}>
<h1 className={styles.title}>
<a href={kitsuUrl} target="_blank" rel="noreferrer">
{record.titles.preferred}
</a>
</h1>
</BannerImage>
</div>
<div className={styles.post}>
<textarea
className={styles.postBody}
value={post}
onChange={(e) => setPost(e.target.value)}
/>

<button
className={styles.submitPost}
onClick={
handleSubmit
}>{`Completed ${unitPrefix} ${unitNumber}`}</button>
</div>
</>
);
}
Loading
Loading