mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-21 22:50:59 -05:00
feat: add disable / delete funct; bump revolt-api
This commit is contained in:
parent
e0ca1681bd
commit
6be0807433
8 changed files with 47 additions and 26 deletions
|
@ -145,7 +145,7 @@
|
|||
"react-router-dom": "^5.2.0",
|
||||
"react-scroll": "^1.8.2",
|
||||
"react-virtuoso": "^2.12.0",
|
||||
"revolt.js": "6.0.2",
|
||||
"revolt.js": "6.0.3",
|
||||
"rimraf": "^3.0.2",
|
||||
"sass": "^1.35.1",
|
||||
"shade-blend-color": "^1.0.0",
|
||||
|
|
|
@ -177,7 +177,7 @@ export function SpecialInputModal(props: SpecialProps) {
|
|||
question={"Add Friend"}
|
||||
callback={(username) =>
|
||||
client.api
|
||||
.put(`/users/${username as ""}/friend`)
|
||||
.post(`/users/friend`, { username })
|
||||
.then(undefined)
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -3,7 +3,7 @@ import { observer } from "mobx-react-lite";
|
|||
import { Client } from "revolt.js";
|
||||
|
||||
import { createContext } from "preact";
|
||||
import { useContext, useEffect, useState } from "preact/hooks";
|
||||
import { useCallback, useContext, useEffect, useState } from "preact/hooks";
|
||||
|
||||
import { Preloader } from "@revoltchat/ui";
|
||||
|
||||
|
@ -29,7 +29,7 @@ export interface ClientOperations {
|
|||
|
||||
export const AppContext = createContext<Client>(null!);
|
||||
export const StatusContext = createContext<ClientStatus>(null!);
|
||||
export const LogOutContext = createContext(() => {});
|
||||
export const LogOutContext = createContext((avoidReq?: boolean) => {});
|
||||
|
||||
type Props = {
|
||||
children: Children;
|
||||
|
@ -42,10 +42,10 @@ export default observer(({ children }: Props) => {
|
|||
const [status, setStatus] = useState(ClientStatus.LOADING);
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
|
||||
function logout() {
|
||||
const logout = useCallback((avoidReq?: boolean) => {
|
||||
setLoaded(false);
|
||||
client.logout(false);
|
||||
}
|
||||
client.logout(avoidReq);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (navigator.onLine) {
|
||||
|
|
|
@ -58,7 +58,7 @@ export interface LegacySyncOptions {
|
|||
export interface LegacyAuthState {
|
||||
accounts: {
|
||||
[key: string]: {
|
||||
session: API.Session;
|
||||
session: Session;
|
||||
};
|
||||
};
|
||||
active?: string;
|
||||
|
|
|
@ -8,7 +8,7 @@ import Persistent from "../interfaces/Persistent";
|
|||
import Store from "../interfaces/Store";
|
||||
|
||||
interface Account {
|
||||
session: API.Session;
|
||||
session: Session;
|
||||
}
|
||||
|
||||
export interface Data {
|
||||
|
@ -82,7 +82,7 @@ export default class Auth implements Store, Persistent<Data> {
|
|||
* Add a new session to the auth manager.
|
||||
* @param session Session
|
||||
*/
|
||||
@action setSession(session: API.Session) {
|
||||
@action setSession(session: Session) {
|
||||
this.sessions.set(session.user_id, { session });
|
||||
this.current = session.user_id;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import { stopPropagation } from "../../../lib/stopPropagation";
|
|||
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
||||
import {
|
||||
ClientStatus,
|
||||
LogOutContext,
|
||||
StatusContext,
|
||||
useClient,
|
||||
} from "../../../context/revoltjs/RevoltClient";
|
||||
|
@ -30,6 +31,7 @@ import UserIcon from "../../../components/common/user/UserIcon";
|
|||
|
||||
export const Account = observer(() => {
|
||||
const { openScreen, writeClipboard } = useIntermediate();
|
||||
const logOut = useContext(LogOutContext);
|
||||
const status = useContext(StatusContext);
|
||||
|
||||
const client = useClient();
|
||||
|
@ -207,9 +209,15 @@ export const Account = observer(() => {
|
|||
"Disable your account. You won't be able to access it unless you contact support."
|
||||
}
|
||||
action="chevron"
|
||||
onClick={() => {
|
||||
//
|
||||
}}>
|
||||
onClick={() =>
|
||||
client.api
|
||||
.post("/auth/account/disable", undefined, {
|
||||
headers: {
|
||||
"X-MFA-Ticket": "TICKET",
|
||||
},
|
||||
})
|
||||
.then(() => logOut(true))
|
||||
}>
|
||||
<Text id="app.settings.pages.account.manage.disable" />
|
||||
</CategoryButton>
|
||||
<CategoryButton
|
||||
|
@ -218,9 +226,15 @@ export const Account = observer(() => {
|
|||
"Your account will be queued for deletion, a confirmation email will be sent."
|
||||
}
|
||||
action="chevron"
|
||||
onClick={() => {
|
||||
//
|
||||
}}>
|
||||
onClick={() =>
|
||||
client.api
|
||||
.post("/auth/account/delete", undefined, {
|
||||
headers: {
|
||||
"X-MFA-Ticket": "TICKET",
|
||||
},
|
||||
})
|
||||
.then(() => logOut(true))
|
||||
}>
|
||||
<Text id="app.settings.pages.account.manage.delete" />
|
||||
</CategoryButton>
|
||||
<Tip>
|
||||
|
|
7
src/types/revolt-api.d.ts
vendored
Normal file
7
src/types/revolt-api.d.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
// TODO: re-export from revolt-api in some way
|
||||
declare type Session = {
|
||||
_id: string;
|
||||
token: string;
|
||||
name: string;
|
||||
user_id: string;
|
||||
};
|
20
yarn.lock
20
yarn.lock
|
@ -3578,7 +3578,7 @@ __metadata:
|
|||
react-router-dom: ^5.2.0
|
||||
react-scroll: ^1.8.2
|
||||
react-virtuoso: ^2.12.0
|
||||
revolt.js: 6.0.2
|
||||
revolt.js: 6.0.3
|
||||
rimraf: ^3.0.2
|
||||
sass: ^1.35.1
|
||||
shade-blend-color: ^1.0.0
|
||||
|
@ -6858,20 +6858,20 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"revolt-api@npm:0.5.3-5-patch.4":
|
||||
version: 0.5.3-5-patch.4
|
||||
resolution: "revolt-api@npm:0.5.3-5-patch.4"
|
||||
"revolt-api@npm:0.5.3-7":
|
||||
version: 0.5.3-7
|
||||
resolution: "revolt-api@npm:0.5.3-7"
|
||||
dependencies:
|
||||
"@insertish/oapi": 0.1.16
|
||||
axios: ^0.26.1
|
||||
lodash.defaultsdeep: ^4.6.1
|
||||
checksum: 4f01c43bff96c4030d13ab0bb5dc83614445763602cfdd8b3ff1dbf61620446a22513ca259bbfc9c490f6b9b19c79d610921a252b667d25adf4040b4222d98cf
|
||||
checksum: acc2f412d1be90f0cfa8a24ba715d8257813762c56ba0e48c649efff349674517036a8fa5939eda61ce31fd64a37f0c54af3d8fae56edf4596f05b10304e090e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"revolt.js@npm:6.0.2":
|
||||
version: 6.0.2
|
||||
resolution: "revolt.js@npm:6.0.2"
|
||||
"revolt.js@npm:6.0.3":
|
||||
version: 6.0.3
|
||||
resolution: "revolt.js@npm:6.0.3"
|
||||
dependencies:
|
||||
"@insertish/exponential-backoff": 3.1.0-patch.2
|
||||
"@insertish/isomorphic-ws": ^4.0.1
|
||||
|
@ -6882,10 +6882,10 @@ __metadata:
|
|||
lodash.isequal: ^4.5.0
|
||||
long: ^5.2.0
|
||||
mobx: ^6.3.2
|
||||
revolt-api: 0.5.3-5-patch.4
|
||||
revolt-api: 0.5.3-7
|
||||
ulid: ^2.3.0
|
||||
ws: ^8.2.2
|
||||
checksum: 1b0c6ce0ceae5d20aec373f24432a5e804677c455fbc39edadaeb6ae0427a0b4fe2ea2b950df92262cd56a43e3f8759d80887b65d66111882b6ecb82e813ff38
|
||||
checksum: cfecbde7a9b795da75bfac3cec05f2aed5fd02cd14fcac1b2fad26285de1b887cf7ccb339e8a63a019f1e83058b041305927e029d7b5eedcc00823582d9a842a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
|
Loading…
Reference in a new issue