@replyke/expo
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
37 lines • 1.23 kB
JavaScript
import * as SecureStore from "expo-secure-store";
import { useAccountSync, useProject, handleError } from "@replyke/core";
const STORAGE_KEY_PREFIX = "replyke-accounts:";
const secureStoreStorage = {
async getAccountMap(projectId) {
try {
const raw = await SecureStore.getItemAsync(`${STORAGE_KEY_PREFIX}${projectId}`);
return raw ? JSON.parse(raw) : null;
}
catch {
return null;
}
},
async setAccountMap(projectId, map) {
try {
await SecureStore.setItemAsync(`${STORAGE_KEY_PREFIX}${projectId}`, JSON.stringify(map));
}
catch (error) {
handleError(error, "Failed to write account map to SecureStore");
}
},
async deleteAccountMap(projectId) {
try {
await SecureStore.deleteItemAsync(`${STORAGE_KEY_PREFIX}${projectId}`);
}
catch (error) {
handleError(error, "Failed to delete account map from SecureStore");
}
},
};
function AccountManager() {
const { projectId } = useProject();
useAccountSync(secureStoreStorage, projectId);
return null;
}
export default AccountManager;
//# sourceMappingURL=AccountManager.js.map