assembly/composables/useAccountNames.ts

28 lines
550 B
TypeScript
Raw Permalink Normal View History

2021-08-20 21:32:30 +00:00
import { onMounted, ref } from "@nuxtjs/composition-api";
const store = ref({});
export function useAccountNames() {
onMounted(() => {
store.value = JSON.parse(
window.localStorage.getItem(`account-names`) || "{}"
);
});
function getAccountName(accountId) {
return store.value[accountId] || "";
}
function setAccountName(accountId, name) {
store.value[accountId] = name;
window.localStorage.setItem(`account-names`, JSON.stringify(store.value));
}
return {
getAccountName,
setAccountName
};
}