mirror of
https://github.com/Instadapp/assembly.git
synced 2024-07-29 22:37:06 +00:00
28 lines
550 B
TypeScript
28 lines
550 B
TypeScript
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
|
|
};
|
|
}
|