From cb436c0cc41ef0bcad476ecc8b7fe2111e84433e Mon Sep 17 00:00:00 2001 From: Nigel Breslaw Date: Thu, 15 Feb 2024 19:32:18 +0100 Subject: [PATCH] Add MMKV for key value data (#379) In memory key value store. For now mobile will save the json files here, but web has limits as the store uses local storage. Instead web will store huge JSON blobs using IndexedDB. This isn't a long term solution for mobile. At some point some kind of SQL database is needed. But that can come after more of the app does useful things. --- native_gg/ios/Podfile.lock | 14 ++++++++++++++ native_gg/package.json | 1 + native_gg/pnpm-lock.yaml | 13 +++++++++++++ native_gg/src/backend/api.ts | 6 ------ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/native_gg/ios/Podfile.lock b/native_gg/ios/Podfile.lock index 1b002681a..69fe9d73a 100644 --- a/native_gg/ios/Podfile.lock +++ b/native_gg/ios/Podfile.lock @@ -282,6 +282,9 @@ PODS: - libwebp/sharpyuv (1.3.2) - libwebp/webp (1.3.2): - libwebp/sharpyuv + - MMKV (1.3.3): + - MMKVCore (~> 1.3.3) + - MMKVCore (1.3.3) - RCT-Folly (2022.05.16.00): - boost - DoubleConversion @@ -1159,6 +1162,9 @@ PODS: - React-Mapbuffer (0.73.4): - glog - React-debug + - react-native-mmkv (2.12.1): + - MMKV (>= 1.3.3) + - React-Core - React-nativeconfig (0.73.4) - React-NativeModulesApple (0.73.4): - glog @@ -1450,6 +1456,7 @@ DEPENDENCIES: - React-jsitracing (from `../node_modules/react-native/ReactCommon/hermes/executor/`) - React-logger (from `../node_modules/react-native/ReactCommon/logger`) - React-Mapbuffer (from `../node_modules/react-native/ReactCommon`) + - react-native-mmkv (from `../node_modules/react-native-mmkv`) - React-nativeconfig (from `../node_modules/react-native/ReactCommon`) - React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`) - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) @@ -1484,6 +1491,8 @@ SPEC REPOS: - libevent - libvmaf - libwebp + - MMKV + - MMKVCore - SDWebImage - SDWebImageAVIFCoder - SDWebImageSVGCoder @@ -1582,6 +1591,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/logger" React-Mapbuffer: :path: "../node_modules/react-native/ReactCommon" + react-native-mmkv: + :path: "../node_modules/react-native-mmkv" React-nativeconfig: :path: "../node_modules/react-native/ReactCommon" React-NativeModulesApple: @@ -1663,6 +1674,8 @@ SPEC CHECKSUMS: libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 libvmaf: 27f523f1e63c694d14d534cd0fddd2fab0ae8711 libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009 + MMKV: f902fb6719da13c2ab0965233d8963a59416f911 + MMKVCore: d26e4d3edd5cb8588c2569222cbd8be4231374e9 RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0 RCTRequired: ab7f915c15569f04a49669e573e6e319a53f9faa RCTTypeSafety: 63b97ced7b766865057e7154db0e81ce4ee6cf1e @@ -1685,6 +1698,7 @@ SPEC CHECKSUMS: React-jsitracing: e8a2dafb9878dbcad02b6b2b88e66267fb427b74 React-logger: 0a57b68dd2aec7ff738195f081f0520724b35dab React-Mapbuffer: 63913773ed7f96b814a2521e13e6d010282096ad + react-native-mmkv: 124b22209aacdcd172b6ac39071b9647080f0411 React-nativeconfig: d7af5bae6da70fa15ce44f045621cf99ed24087c React-NativeModulesApple: 0123905d5699853ac68519607555a9a4f5c7b3ac React-perflogger: 8a1e1af5733004bdd91258dcefbde21e0d1faccd diff --git a/native_gg/package.json b/native_gg/package.json index 553e1453e..48980793f 100644 --- a/native_gg/package.json +++ b/native_gg/package.json @@ -34,6 +34,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.73.4", + "react-native-mmkv": "2.12.1", "react-native-web": "0.19.10", "valibot": "0.28.1" }, diff --git a/native_gg/pnpm-lock.yaml b/native_gg/pnpm-lock.yaml index 7508be4d6..87def8b79 100644 --- a/native_gg/pnpm-lock.yaml +++ b/native_gg/pnpm-lock.yaml @@ -62,6 +62,9 @@ dependencies: react-native: specifier: 0.73.4 version: 0.73.4(@babel/core@7.23.9)(@babel/preset-env@7.23.9)(react@18.2.0) + react-native-mmkv: + specifier: 2.12.1 + version: 2.12.1(react-native@0.73.4)(react@18.2.0) react-native-web: specifier: 0.19.10 version: 0.19.10(react-dom@18.2.0)(react@18.2.0) @@ -7842,6 +7845,16 @@ packages: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} dev: false + /react-native-mmkv@2.12.1(react-native@0.73.4)(react@18.2.0): + resolution: {integrity: sha512-VB0JQc4JoEmmeK134skkce0wwNNUPPLfjO1eXM3o5NS8oeutv2mbUzoLYM3o/1wSIJkMETmT2t0JT4S378RZzA==} + peerDependencies: + react: '*' + react-native: '>=0.71.0' + dependencies: + react: 18.2.0 + react-native: 0.73.4(@babel/core@7.23.9)(@babel/preset-env@7.23.9)(react@18.2.0) + dev: false + /react-native-web@0.19.10(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-IQoHiTQq8egBCVVwmTrYcFLgEFyb4LMZYEktHn4k22JMk9+QTCEz5WTfvr+jdNoeqj/7rtE81xgowKbfGO74qg==} peerDependencies: diff --git a/native_gg/src/backend/api.ts b/native_gg/src/backend/api.ts index e6bb951d6..9591a133a 100644 --- a/native_gg/src/backend/api.ts +++ b/native_gg/src/backend/api.ts @@ -1,12 +1,6 @@ export function getCustomItemDefinition(language = "en"): Promise { - const headers = new Headers(); - headers.append("Cache-Control", "no-cache"); - headers.append("Pragma", "no-cache"); - headers.append("Content-Type", "application/json"); - const requestOptions: RequestInit = { method: "GET", - headers: headers, }; return new Promise((resolve, reject) => {