mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 06:06:41 +01:00
Fix default tag always wrong location
Feel so dumb looking back at this code lol
This commit is contained in:
parent
4e53b1e17f
commit
ced30a9602
1 changed files with 4 additions and 4 deletions
|
@ -2,6 +2,7 @@ import './accounts.css';
|
|||
|
||||
import { Menu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import { useReducer, useState } from 'preact/hooks';
|
||||
import { useReducer } from 'preact/hooks';
|
||||
|
||||
import Avatar from '../components/avatar';
|
||||
import Icon from '../components/icon';
|
||||
|
@ -18,7 +19,6 @@ function Accounts({ onClose }) {
|
|||
const accounts = store.local.getJSON('accounts');
|
||||
const currentAccount = store.session.get('currentAccount');
|
||||
const moreThanOneAccount = accounts.length > 1;
|
||||
const [currentDefault, setCurrentDefault] = useState(0);
|
||||
|
||||
const [_, reload] = useReducer((x) => x + 1, 0);
|
||||
|
||||
|
@ -37,9 +37,9 @@ function Accounts({ onClose }) {
|
|||
<ul class="accounts-list">
|
||||
{accounts.map((account, i) => {
|
||||
const isCurrent = account.info.id === currentAccount;
|
||||
const isDefault = i === (currentDefault || 0);
|
||||
const isDefault = i === 0; // first account is always default
|
||||
return (
|
||||
<li key={i + account.id}>
|
||||
<li key={account.info.id}>
|
||||
<div>
|
||||
{moreThanOneAccount && (
|
||||
<span class={`current ${isCurrent ? 'is-current' : ''}`}>
|
||||
|
@ -120,7 +120,7 @@ function Accounts({ onClose }) {
|
|||
accounts.splice(i, 1);
|
||||
accounts.unshift(account);
|
||||
store.local.setJSON('accounts', accounts);
|
||||
setCurrentDefault(i);
|
||||
reload();
|
||||
}}
|
||||
>
|
||||
<Icon icon="check-circle" />
|
||||
|
|
Loading…
Reference in a new issue