commit 289124b1eab90409e96c23df2b14f2cd9b51e5e0
parent 501ea9fe72d7ad3f1f251ac93f01079ea1df1203
Author: MTRNord <mtrnord1@gmail.com>
Date: Mon, 7 Feb 2022 19:55:31 +0100
Add more tests for Header state and remove flaky tests as well as making sure header properly updates.
Diffstat:
11 files changed, 99 insertions(+), 416 deletions(-)
diff --git a/components/FrontPageImage.tsx b/components/FrontPageImage.tsx
@@ -78,7 +78,7 @@ export default class FrontPageImage extends PureComponent<Props, State> {
await this.context.client?.registerAsGuest(serverUrl);
this.context.is_generating_guest = false;
if (typeof window !== "undefined") {
- window.location.reload();
+ // window.location.reload();
}
} catch (error) {
console.error("Failed to register as guest:", error);
@@ -155,13 +155,15 @@ export default class FrontPageImage extends PureComponent<Props, State> {
return (
<li style={{ height: this.state.imageHeight }} key={id}>
<Link href={direct_link} passHref>
- <div style={{ height: this.state.imageHeight }} className={`relative cursor-pointer`}>
- {image}
- <div style={{ height: this.state.imageHeight }} className={`flex-col max-w-full opacity-0 hover:opacity-100 duration-300 absolute bg-gradient-to-b from-transparent to-black/[.25] inset-0 z-10 flex justify-end items-start text-white p-4`}>
- <h2 className='truncate max-w-full text-base font-semibold'>{caption}</h2>
- <p className='truncate max-w-full text-sm'>{this.state.displayname}</p>
+ <a title={caption}>
+ <div style={{ height: this.state.imageHeight }} className={`relative cursor-pointer`}>
+ {image}
+ <div style={{ height: this.state.imageHeight }} className={`flex-col max-w-full opacity-0 hover:opacity-100 duration-300 absolute bg-gradient-to-b from-transparent to-black/[.25] inset-0 z-10 flex justify-end items-start text-white p-4`}>
+ <h2 className='truncate max-w-full text-base font-semibold'>{caption}</h2>
+ <p className='truncate max-w-full text-sm'>{this.state.displayname}</p>
+ </div>
</div>
- </div>
+ </a>
</Link>
</li>
);
diff --git a/components/Header.tsx b/components/Header.tsx
@@ -1,21 +1,20 @@
import Link from "next/link";
-import { PureComponent } from "react";
+import { Component } from "react";
import User from "../helpers/db/Users";
import { ClientContext } from "./ClientContext";
import { i18n } from 'next-i18next';
import { toast } from "react-toastify";
type Props = {
-
};
type State = {
directory_data: User[];
loading: boolean;
error?: string;
- loggedIn: boolean;
+ loggedIn?: boolean;
};
-export default class Header extends PureComponent<Props, State> {
+export default class Header extends Component<Props, State> {
declare context: React.ContextType<typeof ClientContext>;
constructor(props: Props) {
super(props);
@@ -23,13 +22,22 @@ export default class Header extends PureComponent<Props, State> {
this.state = {
directory_data: [],
loading: true,
- loggedIn: false
+ loggedIn: undefined
} as State;
}
+ shouldComponentUpdate(nextProps: Readonly<Props>, nextState: Readonly<State>, nextContext: React.ContextType<typeof ClientContext>) {
+ if (typeof window !== "undefined" && (nextState.loggedIn === undefined || nextState.loggedIn !== !nextContext.client.isGuest)) {
+ return true;
+ }
+ if (nextProps !== this.props || nextState !== this.state || nextContext !== this.context) {
+ return true;
+ }
+ return false;
+ }
+
componentDidUpdate(prevProps: Props, prevState: State) {
if (this.state.error && this.state.error !== prevState.error) {
- toast.dismiss();
toast(() => <div><h2 className="text-xl text-white">{i18n?.t("Error")}</h2><br />{this.state.error}</div>, {
autoClose: false
});
@@ -41,7 +49,7 @@ export default class Header extends PureComponent<Props, State> {
const data = await fetch("/api/directory", { method: "GET" });
const data_parsed = await data.json();
const directory_data = data_parsed.data;
- this.setState({ directory_data: directory_data, loading: false, loggedIn: !this.context.client.isGuest});
+ this.setState({ directory_data: directory_data, loading: false });
} catch {
console.error("Failed to get directory");
this.setState({ error: "Failed to get directory" });
@@ -51,6 +59,7 @@ export default class Header extends PureComponent<Props, State> {
if (this.state.loading) {
return <></>;
}
+ const loggedIn = (typeof window === "undefined") ? undefined : this.context.client.isGuest !== undefined ? (!this.context.client.isGuest) : undefined;
return (
<>
<header className='bg-[#f8f8f8] dark:bg-[#06070D] flex fixed top-0 left-0 right-0 lg:h-20 h-auto z-[100] items-center lg:flex-row flex-col shadow-black drop-shadow-xl'>
@@ -82,19 +91,19 @@ export default class Header extends PureComponent<Props, State> {
</div>
<nav className='flex lg:flex-shrink-0 my-4'>
- {!this.state.loggedIn ? <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/register">{i18n?.t('Join')}</Link></span> : undefined}
- {!this.state.loggedIn ? <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/login">{i18n?.t('Log in')}</Link></span> : undefined}
- {this.state.loggedIn && this.state.directory_data.some(thing => thing.mxid == this.context.client.userId) ? <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href={"/profile/" + encodeURIComponent(this.context.client.userId!)}>{i18n?.t('Profile')}</Link></span> : undefined}
- {this.state.loggedIn ? <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/logout/">{i18n?.t('Logout')}</Link></span> : undefined}
+ {!loggedIn ? <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/register">{i18n?.t('Join')}</Link></span> : undefined}
+ {!loggedIn ? <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/login">{i18n?.t('Log in')}</Link></span> : undefined}
+ {loggedIn && this.state.directory_data.some(thing => thing.mxid == this.context.client.userId) ? <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href={"/profile/" + encodeURIComponent(this.context.client.userId!)}>{i18n?.t('Profile')}</Link></span> : undefined}
+ {loggedIn ? <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/logout/">{i18n?.t('Logout')}</Link></span> : undefined}
</nav>
</div>
- {this.state.loggedIn ? <span className='lg:opacity-100 opacity-0 inline-block bg-gray-900 dark:bg-gray-200 w-[1px] lg:h-7 h-0'></span> : <span className="mr-4"></span>}
+ {loggedIn ? <span className='lg:opacity-100 opacity-0 inline-block bg-gray-900 dark:bg-gray-200 w-[1px] lg:h-7 h-0'></span> : <span className="mr-4"></span>}
<div className='relative lg:m-0'>
<div className='flex'>
{
this.state.directory_data.some(thing => thing.mxid == this.context.client.userId) ?
- <Link href="/submit"><a className='inline-flex justify-center items-center text-teal-400 hover:text-teal-200 bg-transparent relative h-14 min-w-[9.25rem] z-[2] cursor-pointer font-bold'>{i18n?.t('Submit')}</a></Link> :
- (this.state.loggedIn ? <a className='inline-flex justify-center items-center text-teal-400 hover:text-teal-200 bg-transparent relative h-14 min-w-[9.25rem] z-[2] cursor-pointer font-bold'>{i18n?.t('Setup Account')}</a> : undefined)
+ (loggedIn ? <Link href="/submit"><a className='inline-flex justify-center items-center text-teal-400 hover:text-teal-200 bg-transparent relative h-14 min-w-[9.25rem] z-[2] cursor-pointer font-bold'>{i18n?.t('Submit')}</a></Link> : undefined) :
+ (loggedIn ? <a className='inline-flex justify-center items-center text-teal-400 hover:text-teal-200 bg-transparent relative h-14 min-w-[9.25rem] z-[2] cursor-pointer font-bold'>{i18n?.t('Setup Account')}</a> : undefined)
}
</div>
</div>
diff --git a/e2e/checkEnglishWorks.spec.ts b/e2e/checkEnglishWorks.spec.ts
@@ -0,0 +1,31 @@
+import { test, expect } from '@playwright/test';
+
+test.use({
+ locale: 'en'
+});
+
+test('test if we have english words', async ({ page, baseURL }) => {
+ page.on('console', msg => console.log(msg.text()));
+ // Go to http://localhost:3000/
+ await page.goto(baseURL || 'http://localhost:3000/');
+
+ expect(await page.locator("text=Home").isVisible());
+});
+
+test('test if the header is there and english with correct state', async ({ page, baseURL }) => {
+ page.on('console', msg => console.log(msg.text()));
+ // Go to http://localhost:3000/
+ await page.goto(baseURL || 'http://localhost:3000/');
+
+ // Make sure that we have the Hader
+ expect(await page.locator('header').isVisible()).toBeTruthy();
+
+ // Make sure unauthenticated state is correct
+ expect(await page.locator('header > div > nav > span > a:has-text("Join")').isVisible()).toBeTruthy();
+ expect(await page.locator('header > div > nav > span > a:has-text("Log in")').isVisible()).toBeTruthy();
+ expect(await page.locator('header > div > nav > span > a:has-text("Log in")')).toHaveAttribute("href", "/login");
+
+ // Make sure unauthenticated state is correct and not bleeding
+ expect(await page.locator('header > div > div > a:has-text("Submit")').isVisible()).toBeFalsy();
+ expect(await page.locator('header > div > div > a:has-text("Setup Account")').isVisible()).toBeFalsy();
+});
+\ No newline at end of file
diff --git a/e2e/home.spec.ts b/e2e/home.spec.ts
@@ -1,26 +0,0 @@
-import { test, expect } from '@playwright/test';
-
-test('test navigation to details', async ({ page, baseURL }) => {
- page.on('console', msg => console.log(msg.text()));
-
- // Go to http://localhost:3000/
- await page.goto(baseURL || "http://localhost:3000");
- // Check for the Home text
- await expect(page.locator('h1')).toContainText('Home');
- // Click text=Flowers@mtrnord:art.midnightthoughts.space
- await Promise.all([
- page.waitForNavigation(/*{ url: 'http://localhost:3000/post/%24ugLG5srr5AyYCIhL1CnD6KikH8QYsDVMUHQ9jQRn990' }*/),
- page.click('text=FlowersMTRNord @ Art')
- ]);
-
-
- await expect(page).toHaveURL(`${baseURL || "http://localhost:3000"}/post/%24xoIMe7tUMb2NhCBZaxsZr2CVkptCVu1GaJ_eJMKbJQo`);
-
-
- // Click svg
- await Promise.all([
- page.waitForNavigation(/*{ url: 'http://localhost:3000/' }*/),
- page.click('#matrix-art-logo')
- ]);
- await expect(page).toHaveURL(baseURL || "http://localhost:3000");
-});
-\ No newline at end of file
diff --git a/e2e/navigateToDetails.spec.ts b/e2e/navigateToDetails.spec.ts
@@ -0,0 +1,30 @@
+import { test, expect } from '@playwright/test';
+
+test.use({
+ locale: 'en'
+});
+
+test('test navigation to details', async ({ page, baseURL }) => {
+ page.on('console', msg => console.log(msg.text()));
+
+ // Go to http://localhost:3000/
+ await page.goto(baseURL || "http://localhost:3000");
+ // Check for the Home text
+ await expect(page.locator('h1')).toContainText('Home');
+ // Click text=Flowers@mtrnord:art.midnightthoughts.space
+ await Promise.all([
+ page.waitForNavigation(/*{ url: 'http://localhost:3000/post/%24ugLG5srr5AyYCIhL1CnD6KikH8QYsDVMUHQ9jQRn990' }*/),
+ page.click('text=Flowers')
+ ]);
+
+
+ await expect(page).toHaveURL(`${baseURL || "http://localhost:3000"}/post/%24xoIMe7tUMb2NhCBZaxsZr2CVkptCVu1GaJ_eJMKbJQo`);
+
+
+ // Click svg
+ await Promise.all([
+ page.waitForNavigation(/*{ url: 'http://localhost:3000/' }*/),
+ page.click('#matrix-art-logo')
+ ]);
+ await expect(page).toHaveURL(baseURL || "http://localhost:3000");
+});
+\ No newline at end of file
diff --git a/helpers/matrix_client.ts b/helpers/matrix_client.ts
@@ -40,7 +40,7 @@ export default class MatrixClient {
this.serverUrl = storage.getItem("serverUrl");
this._userId = storage.getItem("userId");
this._accessToken = storage.getItem("accessToken");
- this._isGuest = (this.userId || "").indexOf("@matrix_art_guest_") === 0;
+ this._isGuest = storage.getItem("isGuest");
this.serverName = storage.getItem("serverName");
this._profileRoomId = storage.getItem("profileRoomId");
}
@@ -53,6 +53,7 @@ export default class MatrixClient {
this.storage.setOrDelete("userId", this.userId);
this.storage.setOrDelete("accessToken", this.accessToken);
this.storage.setOrDelete("serverName", this.serverName);
+ this.storage.setOrDelete("isGuest", this.isGuest);
}
private generateToken(len: number) {
diff --git a/helpers/storage.ts b/helpers/storage.ts
@@ -1,4 +1,4 @@
-const STORAGE_VERSION = 2;
+const STORAGE_VERSION = 3;
export default class Storage {
private prefix;
private nodeLocalStorage?: any;
diff --git a/package-lock.json b/package-lock.json
@@ -33,7 +33,6 @@
"@types/node": "17.0.15",
"@types/node-localstorage": "1.3.0",
"@types/offscreencanvas": "2019.6.4",
- "@types/pouchdb": "6.4.0",
"@types/react": "17.0.39",
"@types/validator": "13.7.1",
"autoprefixer": "10.4.2",
@@ -1376,186 +1375,6 @@
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
"dev": true
},
- "node_modules/@types/pouchdb": {
- "version": "6.4.0",
- "resolved": "https://registry.npmjs.org/@types/pouchdb/-/pouchdb-6.4.0.tgz",
- "integrity": "sha512-eGCpX+NXhd5VLJuJMzwe3L79fa9+IDTrAG3CPaf4s/31PD56hOrhDJTSmRELSXuiqXr6+OHzzP0PldSaWsFt7w==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-adapter-cordova-sqlite": "*",
- "@types/pouchdb-adapter-fruitdown": "*",
- "@types/pouchdb-adapter-http": "*",
- "@types/pouchdb-adapter-idb": "*",
- "@types/pouchdb-adapter-leveldb": "*",
- "@types/pouchdb-adapter-localstorage": "*",
- "@types/pouchdb-adapter-memory": "*",
- "@types/pouchdb-adapter-node-websql": "*",
- "@types/pouchdb-adapter-websql": "*",
- "@types/pouchdb-browser": "*",
- "@types/pouchdb-core": "*",
- "@types/pouchdb-http": "*",
- "@types/pouchdb-mapreduce": "*",
- "@types/pouchdb-node": "*",
- "@types/pouchdb-replication": "*"
- }
- },
- "node_modules/@types/pouchdb-adapter-cordova-sqlite": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-cordova-sqlite/-/pouchdb-adapter-cordova-sqlite-1.0.1.tgz",
- "integrity": "sha512-nqlXpW1ho3KBg1mUQvZgH2755y3z/rw4UA7ZJCPMRTHofxGMY8izRVw5rHBL4/7P615or0J2udpRYxgkT3D02g==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-adapter-fruitdown": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-fruitdown/-/pouchdb-adapter-fruitdown-6.1.3.tgz",
- "integrity": "sha512-Wz1Z1JLOW1hgmFQjqnSkmyyfH7by/iWb4abKn684WMvQfmxx6BxKJpJ4+eulkVPQzzgMMSgU1MpnQOm9FgRkbw==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-adapter-http": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-http/-/pouchdb-adapter-http-6.1.3.tgz",
- "integrity": "sha512-9Z4TLbF/KJWy/D2sWRPBA+RNU0odQimfdvlDX+EY7rGcd3aVoH8qjD/X0Xcd/0dfBH5pKrNIMFFQgW/TylRCmA==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-adapter-idb": {
- "version": "6.1.4",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-idb/-/pouchdb-adapter-idb-6.1.4.tgz",
- "integrity": "sha512-KIAXbkF4uYUz0ZwfNEFLtEkK44mEWopAsD76UhucH92XnJloBysav+TjI4FFfYQyTjoW3S1s6V+Z14CUJZ0F6w==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-adapter-leveldb": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-leveldb/-/pouchdb-adapter-leveldb-6.1.3.tgz",
- "integrity": "sha512-ex8NFqQGFwEpFi7AaZ5YofmuemfZNsL3nTFZBUCAKYMBkazQij1pe2ILLStSvJr0XS0qxgXjCEW19T5Wqiiskg==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-adapter-localstorage": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-localstorage/-/pouchdb-adapter-localstorage-6.1.3.tgz",
- "integrity": "sha512-oor040tye1KKiGLWYtIy7rRT7C2yoyX3Tf6elEJRpjOA7Ja/H8lKc4LaSh9ATbptIcES6MRqZDxtp7ly9hsW3Q==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-adapter-memory": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-memory/-/pouchdb-adapter-memory-6.1.3.tgz",
- "integrity": "sha512-gVbsIMzDzgZYThFVT4eVNsmuZwVm/4jDxP1sjlgc3qtDIxbtBhGgyNfcskwwz9Zu5Lv1avkDsIWvcxQhnvRlHg==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-adapter-node-websql": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-node-websql/-/pouchdb-adapter-node-websql-6.1.3.tgz",
- "integrity": "sha512-F/P+os6Jsa7CgHtH64+Z0HfwIcj0hIRB5z8gNhF7L7dxPWoAfkopK5H2gydrP3sQrlGyN4WInF+UJW/Zu1+FKg==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-adapter-websql": "*",
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-adapter-websql": {
- "version": "6.1.4",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-websql/-/pouchdb-adapter-websql-6.1.4.tgz",
- "integrity": "sha512-zMJQCtXC40hBsIDRn0GhmpeGMK0f9l/OGWfLguvczROzxxcOD7REI+e6SEmX7gJKw5JuMvlfuHzkQwjmvSJbtg==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-browser": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-browser/-/pouchdb-browser-6.1.3.tgz",
- "integrity": "sha512-EdYowrWxW9SWBMX/rux2eq7dbHi5Zeyzz+FF/IAsgQKnUxgeCO5VO2j4zTzos0SDyJvAQU+EYRc11r7xGn5tvA==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-adapter-http": "*",
- "@types/pouchdb-adapter-idb": "*",
- "@types/pouchdb-adapter-websql": "*",
- "@types/pouchdb-core": "*",
- "@types/pouchdb-mapreduce": "*",
- "@types/pouchdb-replication": "*"
- }
- },
- "node_modules/@types/pouchdb-core": {
- "version": "7.0.10",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-core/-/pouchdb-core-7.0.10.tgz",
- "integrity": "sha512-mKhjLlWWXyV3PTTjDhzDV1kc2dolO7VYFa75IoKM/hr8Er9eo8RIbS7mJLfC8r/C3p6ihZu9yZs1PWC1LQ0SOA==",
- "dev": true,
- "dependencies": {
- "@types/debug": "*",
- "@types/pouchdb-find": "*"
- }
- },
- "node_modules/@types/pouchdb-find": {
- "version": "6.3.7",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-find/-/pouchdb-find-6.3.7.tgz",
- "integrity": "sha512-b2dr9xoZRK5Mwl8UiRA9l5j9mmCxNfqXuu63H1KZHwJLILjoIIz7BntCvM0hnlnl7Q8P8wORq0IskuaMq5Nnnw==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-http": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-http/-/pouchdb-http-6.1.3.tgz",
- "integrity": "sha512-0e9E5SqNOyPl/3FnEIbENssB4FlJsNYuOy131nxrZk36S+y1R/6qO7ZVRypWpGTqBWSuVd7gCsq2UDwO/285+w==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-adapter-http": "*",
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-mapreduce": {
- "version": "6.1.6",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-mapreduce/-/pouchdb-mapreduce-6.1.6.tgz",
- "integrity": "sha512-YubC1pKmQGbPrZzYP5vUNrlafMTkO2+AZIumLB39Lkw1rYFxa4pwiKlygtDgJD2Gy+6A5Nu3ShTPrB3kPOXFyg==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*"
- }
- },
- "node_modules/@types/pouchdb-node": {
- "version": "6.1.4",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-node/-/pouchdb-node-6.1.4.tgz",
- "integrity": "sha512-wnTCH8X1JOPpNOfVhz8HW0AvmdHh6pt40MuRj0jQnK7QEHsHS79WujsKTKSOF8QXtPwpvCNSsI7ut7H7tfxxJQ==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-adapter-http": "*",
- "@types/pouchdb-adapter-leveldb": "*",
- "@types/pouchdb-core": "*",
- "@types/pouchdb-mapreduce": "*",
- "@types/pouchdb-replication": "*"
- }
- },
- "node_modules/@types/pouchdb-replication": {
- "version": "6.4.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-replication/-/pouchdb-replication-6.4.3.tgz",
- "integrity": "sha512-Dsyy8EhKGBIQAECKelfvufDjRO5Rsy8RlujVllbjHzu3OGu8cNP92/bykeXXC3hTgvrp5Kviqhh9VON1Iw+M3Q==",
- "dev": true,
- "dependencies": {
- "@types/pouchdb-core": "*",
- "@types/pouchdb-find": "*"
- }
- },
"node_modules/@types/prop-types": {
"version": "15.7.4",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz",
@@ -10149,186 +9968,6 @@
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
"dev": true
},
- "@types/pouchdb": {
- "version": "6.4.0",
- "resolved": "https://registry.npmjs.org/@types/pouchdb/-/pouchdb-6.4.0.tgz",
- "integrity": "sha512-eGCpX+NXhd5VLJuJMzwe3L79fa9+IDTrAG3CPaf4s/31PD56hOrhDJTSmRELSXuiqXr6+OHzzP0PldSaWsFt7w==",
- "dev": true,
- "requires": {
- "@types/pouchdb-adapter-cordova-sqlite": "*",
- "@types/pouchdb-adapter-fruitdown": "*",
- "@types/pouchdb-adapter-http": "*",
- "@types/pouchdb-adapter-idb": "*",
- "@types/pouchdb-adapter-leveldb": "*",
- "@types/pouchdb-adapter-localstorage": "*",
- "@types/pouchdb-adapter-memory": "*",
- "@types/pouchdb-adapter-node-websql": "*",
- "@types/pouchdb-adapter-websql": "*",
- "@types/pouchdb-browser": "*",
- "@types/pouchdb-core": "*",
- "@types/pouchdb-http": "*",
- "@types/pouchdb-mapreduce": "*",
- "@types/pouchdb-node": "*",
- "@types/pouchdb-replication": "*"
- }
- },
- "@types/pouchdb-adapter-cordova-sqlite": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-cordova-sqlite/-/pouchdb-adapter-cordova-sqlite-1.0.1.tgz",
- "integrity": "sha512-nqlXpW1ho3KBg1mUQvZgH2755y3z/rw4UA7ZJCPMRTHofxGMY8izRVw5rHBL4/7P615or0J2udpRYxgkT3D02g==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-adapter-fruitdown": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-fruitdown/-/pouchdb-adapter-fruitdown-6.1.3.tgz",
- "integrity": "sha512-Wz1Z1JLOW1hgmFQjqnSkmyyfH7by/iWb4abKn684WMvQfmxx6BxKJpJ4+eulkVPQzzgMMSgU1MpnQOm9FgRkbw==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-adapter-http": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-http/-/pouchdb-adapter-http-6.1.3.tgz",
- "integrity": "sha512-9Z4TLbF/KJWy/D2sWRPBA+RNU0odQimfdvlDX+EY7rGcd3aVoH8qjD/X0Xcd/0dfBH5pKrNIMFFQgW/TylRCmA==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-adapter-idb": {
- "version": "6.1.4",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-idb/-/pouchdb-adapter-idb-6.1.4.tgz",
- "integrity": "sha512-KIAXbkF4uYUz0ZwfNEFLtEkK44mEWopAsD76UhucH92XnJloBysav+TjI4FFfYQyTjoW3S1s6V+Z14CUJZ0F6w==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-adapter-leveldb": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-leveldb/-/pouchdb-adapter-leveldb-6.1.3.tgz",
- "integrity": "sha512-ex8NFqQGFwEpFi7AaZ5YofmuemfZNsL3nTFZBUCAKYMBkazQij1pe2ILLStSvJr0XS0qxgXjCEW19T5Wqiiskg==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-adapter-localstorage": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-localstorage/-/pouchdb-adapter-localstorage-6.1.3.tgz",
- "integrity": "sha512-oor040tye1KKiGLWYtIy7rRT7C2yoyX3Tf6elEJRpjOA7Ja/H8lKc4LaSh9ATbptIcES6MRqZDxtp7ly9hsW3Q==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-adapter-memory": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-memory/-/pouchdb-adapter-memory-6.1.3.tgz",
- "integrity": "sha512-gVbsIMzDzgZYThFVT4eVNsmuZwVm/4jDxP1sjlgc3qtDIxbtBhGgyNfcskwwz9Zu5Lv1avkDsIWvcxQhnvRlHg==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-adapter-node-websql": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-node-websql/-/pouchdb-adapter-node-websql-6.1.3.tgz",
- "integrity": "sha512-F/P+os6Jsa7CgHtH64+Z0HfwIcj0hIRB5z8gNhF7L7dxPWoAfkopK5H2gydrP3sQrlGyN4WInF+UJW/Zu1+FKg==",
- "dev": true,
- "requires": {
- "@types/pouchdb-adapter-websql": "*",
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-adapter-websql": {
- "version": "6.1.4",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-websql/-/pouchdb-adapter-websql-6.1.4.tgz",
- "integrity": "sha512-zMJQCtXC40hBsIDRn0GhmpeGMK0f9l/OGWfLguvczROzxxcOD7REI+e6SEmX7gJKw5JuMvlfuHzkQwjmvSJbtg==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-browser": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-browser/-/pouchdb-browser-6.1.3.tgz",
- "integrity": "sha512-EdYowrWxW9SWBMX/rux2eq7dbHi5Zeyzz+FF/IAsgQKnUxgeCO5VO2j4zTzos0SDyJvAQU+EYRc11r7xGn5tvA==",
- "dev": true,
- "requires": {
- "@types/pouchdb-adapter-http": "*",
- "@types/pouchdb-adapter-idb": "*",
- "@types/pouchdb-adapter-websql": "*",
- "@types/pouchdb-core": "*",
- "@types/pouchdb-mapreduce": "*",
- "@types/pouchdb-replication": "*"
- }
- },
- "@types/pouchdb-core": {
- "version": "7.0.10",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-core/-/pouchdb-core-7.0.10.tgz",
- "integrity": "sha512-mKhjLlWWXyV3PTTjDhzDV1kc2dolO7VYFa75IoKM/hr8Er9eo8RIbS7mJLfC8r/C3p6ihZu9yZs1PWC1LQ0SOA==",
- "dev": true,
- "requires": {
- "@types/debug": "*",
- "@types/pouchdb-find": "*"
- }
- },
- "@types/pouchdb-find": {
- "version": "6.3.7",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-find/-/pouchdb-find-6.3.7.tgz",
- "integrity": "sha512-b2dr9xoZRK5Mwl8UiRA9l5j9mmCxNfqXuu63H1KZHwJLILjoIIz7BntCvM0hnlnl7Q8P8wORq0IskuaMq5Nnnw==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-http": {
- "version": "6.1.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-http/-/pouchdb-http-6.1.3.tgz",
- "integrity": "sha512-0e9E5SqNOyPl/3FnEIbENssB4FlJsNYuOy131nxrZk36S+y1R/6qO7ZVRypWpGTqBWSuVd7gCsq2UDwO/285+w==",
- "dev": true,
- "requires": {
- "@types/pouchdb-adapter-http": "*",
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-mapreduce": {
- "version": "6.1.6",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-mapreduce/-/pouchdb-mapreduce-6.1.6.tgz",
- "integrity": "sha512-YubC1pKmQGbPrZzYP5vUNrlafMTkO2+AZIumLB39Lkw1rYFxa4pwiKlygtDgJD2Gy+6A5Nu3ShTPrB3kPOXFyg==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*"
- }
- },
- "@types/pouchdb-node": {
- "version": "6.1.4",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-node/-/pouchdb-node-6.1.4.tgz",
- "integrity": "sha512-wnTCH8X1JOPpNOfVhz8HW0AvmdHh6pt40MuRj0jQnK7QEHsHS79WujsKTKSOF8QXtPwpvCNSsI7ut7H7tfxxJQ==",
- "dev": true,
- "requires": {
- "@types/pouchdb-adapter-http": "*",
- "@types/pouchdb-adapter-leveldb": "*",
- "@types/pouchdb-core": "*",
- "@types/pouchdb-mapreduce": "*",
- "@types/pouchdb-replication": "*"
- }
- },
- "@types/pouchdb-replication": {
- "version": "6.4.3",
- "resolved": "https://registry.npmjs.org/@types/pouchdb-replication/-/pouchdb-replication-6.4.3.tgz",
- "integrity": "sha512-Dsyy8EhKGBIQAECKelfvufDjRO5Rsy8RlujVllbjHzu3OGu8cNP92/bykeXXC3hTgvrp5Kviqhh9VON1Iw+M3Q==",
- "dev": true,
- "requires": {
- "@types/pouchdb-core": "*",
- "@types/pouchdb-find": "*"
- }
- },
"@types/prop-types": {
"version": "15.7.4",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz",
diff --git a/package.json b/package.json
@@ -45,7 +45,6 @@
"@types/node": "17.0.15",
"@types/node-localstorage": "1.3.0",
"@types/offscreencanvas": "2019.6.4",
- "@types/pouchdb": "6.4.0",
"@types/react": "17.0.39",
"@types/validator": "13.7.1",
"autoprefixer": "10.4.2",
diff --git a/pages/logout.tsx b/pages/logout.tsx
@@ -23,9 +23,8 @@ class Logout extends PureComponent<Props, State> {
if (!this.context.client.isGuest) {
await this.context.client.logout(false);
}
-
- await this.props.router.replace("/");
}
+ await this.props.router.replace("/");
}
render() {
return <></>;
diff --git a/pages/post/[id].tsx b/pages/post/[id].tsx
@@ -17,14 +17,12 @@ import { isImageEvent, isImageGalleryEvent } from '../../components/FrontPageIma
import Link from 'next/link';
import Footer from '../../components/Footer';
import { Blurhash } from 'react-blurhash';
-import User from '../../helpers/db/Users';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { i18n } from 'next-i18next';
import { toast } from 'react-toastify';
type Props = InferGetServerSidePropsType<typeof getServerSideProps> & {
router: NextRouter;
- directory_data: User[];
};
type State = {