Some light tag sorting
This commit is contained in:
parent
623ea12b74
commit
4cc58bf683
@ -42,6 +42,8 @@ function Account ({ address, allowTags, className, isFavorite, t, toggleFavorite
|
||||
const [isTransferOpen, setIsTransferOpen] = useState(false);
|
||||
const [isVisible, setIsVisible] = useState(true);
|
||||
|
||||
const _setTags = (tags: string[]): void => setTags(tags.sort());
|
||||
|
||||
useEffect((): void => {
|
||||
const account = keyring.getAccount(address);
|
||||
|
||||
@ -51,7 +53,7 @@ function Account ({ address, allowTags, className, isFavorite, t, toggleFavorite
|
||||
isEditable: (account && !(account.meta.isInjected || account.meta.isHardware)) || false,
|
||||
isExternal: (account && account.meta.isExternal) || false
|
||||
});
|
||||
setTags(account?.meta?.tags || []);
|
||||
_setTags(account?.meta?.tags || []);
|
||||
setAccName(account?.meta?.name || '');
|
||||
}, [address]);
|
||||
|
||||
@ -209,7 +211,7 @@ function Account ({ address, allowTags, className, isFavorite, t, toggleFavorite
|
||||
? (
|
||||
<InputTags
|
||||
onBlur={_saveTags}
|
||||
onChange={setTags}
|
||||
onChange={_setTags}
|
||||
onClose={_saveTags}
|
||||
openOnFocus
|
||||
defaultValue={tags}
|
||||
|
||||
@ -43,6 +43,8 @@ function Address ({ address, allowTags, className, isFavorite, t, toggleFavorite
|
||||
const [isTransferOpen, setIsTransferOpen] = useState(false);
|
||||
const [isVisible, setIsVisible] = useState(true);
|
||||
|
||||
const _setTags = (tags: string[]): void => setTags(tags.sort());
|
||||
|
||||
useEffect((): void => {
|
||||
const current = keyring.getAddress(address);
|
||||
|
||||
@ -53,7 +55,7 @@ function Address ({ address, allowTags, className, isFavorite, t, toggleFavorite
|
||||
useEffect((): void => {
|
||||
const account = keyring.getAddress(address);
|
||||
|
||||
setTags(account?.meta?.tags || []);
|
||||
_setTags(account?.meta?.tags || []);
|
||||
setAccName(account?.meta?.name || '');
|
||||
}, [address]);
|
||||
|
||||
@ -192,7 +194,7 @@ function Address ({ address, allowTags, className, isFavorite, t, toggleFavorite
|
||||
? (
|
||||
<InputTags
|
||||
onBlur={_saveTags}
|
||||
onChange={setTags}
|
||||
onChange={_setTags}
|
||||
onClose={_saveTags}
|
||||
openOnFocus
|
||||
defaultValue={tags}
|
||||
|
||||
@ -33,7 +33,7 @@ interface Props extends BareProps {
|
||||
}
|
||||
|
||||
function loadTags (): string[] {
|
||||
return store.get('tags') || ['Default'];
|
||||
return (store.get('tags') || ['Default']).sort();
|
||||
}
|
||||
|
||||
function valueToOption (value: string): Option {
|
||||
@ -44,11 +44,12 @@ const tags = loadTags();
|
||||
const options = tags.map(valueToOption);
|
||||
|
||||
function saveTags (tags: string[]): void {
|
||||
store.set('tags', tags);
|
||||
store.set('tags', tags.sort());
|
||||
}
|
||||
|
||||
function onAddTag (value: string): void {
|
||||
tags.push(value);
|
||||
|
||||
options.push(valueToOption(value));
|
||||
|
||||
saveTags(tags);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user