Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
add utility dev script for clearing all cached data
Browse files Browse the repository at this point in the history
  • Loading branch information
lyqht committed Apr 20, 2022
1 parent 433941b commit 9ae2682
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 8 deletions.
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Billy
# Billy <!-- omit in toc -->

[![Update database types](https://github.com/lyqht/Billy/actions/workflows/update-types.yml/badge.svg)](https://github.com/lyqht/Billy/actions/workflows/update-types.yml)

Expand All @@ -9,6 +9,17 @@

<br />

Table of contents

- [Brief introduction](#brief-introduction)
- [Tech Notes](#tech-notes)
- [Building blocks of this project](#building-blocks-of-this-project)
- [Misc Tech Notes](#misc-tech-notes)
- [Set up instructions](#set-up-instructions)
- [Install dependencies](#install-dependencies)
- [Clearing cache](#clearing-cache)
- [Motivations for building the app](#motivations-for-building-the-app)

## Brief introduction

This project is developed solely by [Estee Tey](https://www.github.com/lyqht). If you are keen on how the app idea came about, you can refer to the [motivations section](#motivations-for-building-the-app).
Expand All @@ -31,11 +42,13 @@ If you are interested on some other tech notes how this app is built (e.g. how t

## Set up instructions

### Install dependencies

Install the node modules & pods

```
npm i
npx pod-install
npx pod-install # if you want to build for ios
```

Then run 1 of the commands
Expand All @@ -44,7 +57,22 @@ npm run ios
npm run android
```

You would need the Supabase project related environment variables as mentioned in `.env.sample`. You can create your own project and replace those values.
You would need the Supabase project related environment variables as mentioned in `.env.sample`. You can create your own Supabase project and replace those values.

### Clearing cache

There is a utility function on `SyncService` for logging the user out, clearing all cache and notifications. Intended mostly for testing purposes.

```ts
const init = async () => {
// add this line for clearing cache temporarily
await SyncService.clearAllData();

await SyncService.syncAllData();
await registerDeviceForRemoteMessages();
};

```

---

Expand All @@ -56,14 +84,11 @@ I had built Billy intended for these few specific target audiences:

My mom & I both like cute stuff, so that's how _Billy_ has its name.

## Memes


<div style="display: grid; place-items:center;">
<img width="350" src="./demo/concerned_billy.png"></img>
</div>

<br />

Some funny tweet threads about Billy:
- [Concerned Billy](https://twitter.com/RubyNovaDev/status/1511390234440839175)
- [When a user is reckless in their waifu purchases](https://twitter.com/estee_tey/status/1512439733409878018)
3 changes: 2 additions & 1 deletion TECH_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ These are some brief ideations of the content models and entities that could be
- Supabase requires `react-native-url-polyfill` on React Native to work ([Reference](https://justinnoel.dev/2020/12/08/react-native-urlsearchparams-error-not-implemented/))
- If creating DB on Supabase that is imported from spreadsheet, the autoincrement index needs to be manually reset. ([Reference](https://github.com/supabase/supabase/issues/1804))
- For using custom storage provider with Supabase on React Native, we have to declare an interface that resembles Async Storage ([Reference](https://github.com/supabase/supabase/issues/6348))
- Integrating UI Kittens Select component with React Hook Form ([Reference](https://github.com/react-hook-form/react-hook-form/discussions/8187))
- Integrating UI Kittens Select component with React Hook Form ([Reference](https://github.com/react-hook-form/react-hook-form/discussions/8187))
- Google App Signing is quite confusing, but here's a [more detailed guide](https://blog.codemagic.io/the-simple-guide-to-android-code-signing/) that I found on this topic. Key password somehow is the same as store password.
7 changes: 7 additions & 0 deletions memes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Memes

Some funny tweet threads about Billy:
- [Concerned Billy](https://twitter.com/RubyNovaDev/status/1511390234440839175)
- [When a user is reckless in their waifu purchases](https://twitter.com/estee_tey/status/1512439733409878018)

Feel free to contribute memes too.
5 changes: 5 additions & 0 deletions src/services/Cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class Cache {
this.storage.delete(STORAGE_KEYS.USER);
}
}

clearAllData(): void {
console.log('clearing all cache');
this.storage.clearAll();
}
}

export default new Cache();
5 changes: 5 additions & 0 deletions src/services/SyncService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class SyncService {

await BillService.getBillsFromDB();
};

clearAllData = async (): Promise<void> => {
Cache.clearAllData();
await UserService.logOutUser();
};
}

export default new SyncService();

0 comments on commit 9ae2682

Please sign in to comment.