refactor: more TS code
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
KEY_TOKEN,
|
||||
KEY_UID
|
||||
} from "../config";
|
||||
import { AuthData, AuthToken, User } from "../../types/auth";
|
||||
import { AuthData, AuthToken, RenewTokenResponse, User } from "../../types/auth";
|
||||
|
||||
interface State {
|
||||
initialized: boolean;
|
||||
@@ -67,7 +67,7 @@ const authDataSlice = createSlice({
|
||||
updateInitialized(state, action: PayloadAction<boolean>) {
|
||||
state.initialized = action.payload;
|
||||
},
|
||||
updateToken(state, action: PayloadAction<AuthToken>) {
|
||||
updateToken(state, action: PayloadAction<RenewTokenResponse>) {
|
||||
const { token, refresh_token, expired_in } = action.payload;
|
||||
state.token = token;
|
||||
const et = +new Date() + Number(expired_in) * 1000;
|
||||
|
||||
@@ -53,7 +53,7 @@ const channelsSlice = createSlice({
|
||||
},
|
||||
updateChannel(state, action: PayloadAction<UpdateChannelDTO>) {
|
||||
const ignoreInPublic = ["add_member", "remove_member"];
|
||||
const { gid, operation, members = [], ...rest } = action.payload;
|
||||
const { gid, operation = "", members = [], ...rest } = action.payload;
|
||||
const currChannel = state.byId[gid];
|
||||
if (!currChannel || (currChannel.is_public && ignoreInPublic.includes(operation))) return;
|
||||
switch (operation) {
|
||||
|
||||
@@ -59,7 +59,7 @@ const uiSlice = createSlice({
|
||||
},
|
||||
updateRememberedNavs(
|
||||
state,
|
||||
action: PayloadAction<{ key?: "chat" | "user"; path: string | null } | undefined>
|
||||
action: PayloadAction<{ key?: "chat" | "user"; path?: string | null } | undefined>
|
||||
) {
|
||||
const { key = "chat", path = null } = action.payload || {};
|
||||
state.rememberedNavs[key] = path;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { isNull, omitBy } from "lodash";
|
||||
import BASE_URL from "../config";
|
||||
import { User } from "../../types/auth";
|
||||
import { User } from "../../types/user";
|
||||
import { UserLog, UserState } from "../../types/sse";
|
||||
|
||||
export interface StoredUser extends User {
|
||||
|
||||
Reference in New Issue
Block a user