phanpy/src/utils/store-utils.js
Lim Chee Aun 71b50382e9 New feature: Unsent Drafts
For now, this only works for unsent unsaved drafts e.g. the browser kill the page without giving the user the chance to discard
2023-01-13 15:30:09 +08:00

18 lines
472 B
JavaScript

import store from './store';
export function getCurrentAccount() {
const accounts = store.local.getJSON('accounts') || [];
const currentAccount = store.session.get('currentAccount');
const account =
accounts.find((a) => a.info.id === currentAccount) || accounts[0];
return account;
}
export function getCurrentAccountNS() {
const account = getCurrentAccount();
const {
instanceURL,
info: { id },
} = account;
return `${id}@${instanceURL}`;
}