Skip to content

Commit

Permalink
Merge pull request #17 from ecency/bugfix/users
Browse files Browse the repository at this point in the history
Bugfix/users
  • Loading branch information
feruzm authored Sep 19, 2024
2 parents 69d7af3 + c76ac5c commit 13389fc
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/api/queries/get-account-full-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const getAccountFullQuery = (username?: string) =>
queryKey: [QueryIdentifiers.GET_ACCOUNT_FULL, username],
queryFn: async () => {
if (!username) {
return;
return null;
}
const response = await getAccount(username);
let follow_stats: AccountFollowStats | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function ProfileInfo({ account }: Props) {
return (
<span className="profile-info">
<StyledTooltip
content={isLoaded && <ProfileInfoContent account={account} rcAccount={rcAccount} />}
content={isLoaded ? <ProfileInfoContent account={account} rcAccount={rcAccount} /> : <></>}
>
{isLoaded ? <UilInfo width={20} height={20} /> : <Spinner className="w-3.5 h-3.5" />}
</StyledTooltip>
Expand Down
2 changes: 2 additions & 0 deletions src/app/client-init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ export function ClientInit() {
const setActiveUser = useGlobalStore((state) => state.setActiveUser);
const updateActiveUser = useGlobalStore((state) => state.updateActiveUser);
const initKeychain = useGlobalStore((state) => state.initKeychain);
const loadUsers = useGlobalStore((state) => state.loadUsers);

const { data } = getAccountFullQuery(activeUser?.username).useClientQuery();

useMount(() => {
initI18next();
loadUsers();

const activeUsername = ls.get("active_user") ?? Cookies.get("active_user");
if (activeUsername) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/global-store/initialization/client-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const useClientGlobalStore = create(
combine(INITIAL_STATE, (set, getState, store) => ({
...createUiActions(set, getState),
...createGlobalActions(set, getState),
...createUsersActions(),
...createUsersActions(set, getState),
...createAuthenticationActions(set, getState),
...createSigningKeyActions(set, getState),
...createNotificationsActions(set, getState)
Expand Down
2 changes: 1 addition & 1 deletion src/core/global-store/initialization/server-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const getServerStore = () =>
combine(INITIAL_STATE, (set, getState, store) => ({
...createUiActions(set, getState),
...createGlobalActions(set, getState),
...createUsersActions(),
...createUsersActions(set, getState),
...createAuthenticationActions(set, getState),
...createSigningKeyActions(set, getState),
...createNotificationsActions(set, getState)
Expand Down
17 changes: 16 additions & 1 deletion src/core/global-store/modules/users-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@ export function createUsersState() {
};
}

export function createUsersActions() {
type State = ReturnType<typeof createUsersState>;

export function createUsersActions(set: (state: Partial<State>) => void, getState: () => State) {
return {
loadUsers: () =>
set({
users: ls.getByPrefix("user_").map((x) => {
const u = decodeObj(x) as User;
return {
username: u.username,
refreshToken: "",
accessToken: "",
expiresIn: u.expiresIn,
postingKey: u.postingKey
};
})
}),
addUser: (user: User) => {
ls.set(`user_${user.username}`, encodeObj(user));
ls.getByPrefix("user_").map((x) => {
Expand Down
1 change: 1 addition & 0 deletions src/styles/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ html {

body {
min-width: 280px;
overflow-x: hidden;

.full-height {
position: absolute;
Expand Down

0 comments on commit 13389fc

Please sign in to comment.