mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 19:28:26 +00:00
Fix updater and SendScreen event handler
This commit is contained in:
@@ -105,3 +105,5 @@ tasks.md
|
||||
# hot-updater
|
||||
.hot-updater/output
|
||||
|
||||
# hot-updater
|
||||
.env.hotupdater
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
019acc82-c83f-745c-b197-db89afcc5a30
|
||||
019ae9c5-c95b-7084-baeb-1f83d682b9b3
|
||||
@@ -1,10 +1,12 @@
|
||||
import { bare } from "@hot-updater/bare";
|
||||
import { withSentry } from "@hot-updater/sentry-plugin";
|
||||
import { firebaseDatabase, firebaseStorage } from "@hot-updater/firebase";
|
||||
import "dotenv/config";
|
||||
import * as admin from "firebase-admin";
|
||||
import { config } from "dotenv";
|
||||
import { defineConfig } from "hot-updater";
|
||||
|
||||
config({ path: ".env" });
|
||||
|
||||
// https://firebase.google.com/docs/admin/setup?hl=en#initialize_the_sdk_in_non-google_environments
|
||||
// Check your .env file and add the credentials
|
||||
// Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to your credentials file path
|
||||
@@ -31,5 +33,5 @@ export default defineConfig({
|
||||
projectId: process.env.HOT_UPDATER_FIREBASE_PROJECT_ID!,
|
||||
credential,
|
||||
}),
|
||||
updateStrategy: "appVersion",
|
||||
updateStrategy: "appVersion", // or "fingerprint"
|
||||
});
|
||||
+9
-9
@@ -21,7 +21,7 @@
|
||||
"machine-translate": "npx @inlang/cli machine translate --project minibits.inlang"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cashu/cashu-ts": "minibits-cash/cashu-ts#b3ba36757d84ec03f1064029db02308eb3a09cc4",
|
||||
"@cashu/cashu-ts": "minibits-cash/cashu-ts#c85d4638c007ac8126bc83a7287a6d848fcc8153",
|
||||
"@fortawesome/fontawesome-svg-core": "^7.1.0",
|
||||
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
||||
"@fortawesome/free-regular-svg-icons": "^7.1.0",
|
||||
@@ -30,12 +30,12 @@
|
||||
"@gandlaf21/bc-ur": "^1.1.12",
|
||||
"@gandlaf21/bolt11-decode": "^3.1.1",
|
||||
"@gocodingnow/rn-size-matters": "^0.0.4",
|
||||
"@hot-updater/react-native": "0.20.11",
|
||||
"@hot-updater/react-native": "0.23.1",
|
||||
"@notifee/react-native": "^9.1.8",
|
||||
"@react-native-clipboard/clipboard": "^1.16.3",
|
||||
"@react-native-community/netinfo": "^11.4.1",
|
||||
"@react-native-firebase/app": "^23.4.0",
|
||||
"@react-native-firebase/messaging": "^23.4.0",
|
||||
"@react-native-firebase/app": "^23.5.0",
|
||||
"@react-native-firebase/messaging": "^23.5.0",
|
||||
"@react-navigation/bottom-tabs": "^7.4.8",
|
||||
"@react-navigation/native": "^7.1.18",
|
||||
"@react-navigation/native-stack": "^7.3.27",
|
||||
@@ -91,8 +91,8 @@
|
||||
"@babel/preset-env": "^7.25.3",
|
||||
"@babel/runtime": "^7.25.0",
|
||||
"@hot-updater/bare": "0.20.11",
|
||||
"@hot-updater/firebase": "0.20.11",
|
||||
"@hot-updater/sentry-plugin": "^0.20.11",
|
||||
"@hot-updater/firebase": "0.23.1",
|
||||
"@hot-updater/sentry-plugin": "^0.23.1",
|
||||
"@react-native-community/cli": "20.0.0",
|
||||
"@react-native-community/cli-platform-android": "20.0.0",
|
||||
"@react-native-community/cli-platform-ios": "20.0.0",
|
||||
@@ -110,9 +110,9 @@
|
||||
"dotenv": "^17.2.3",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-plugin-unused-imports": "^2.0.0",
|
||||
"firebase-admin": "^13.5.0",
|
||||
"firebase-tools": "^14.19.0",
|
||||
"hot-updater": "^0.19.9",
|
||||
"firebase-admin": "^13.6.0",
|
||||
"firebase-tools": "^14.27.0",
|
||||
"hot-updater": "^0.23.1",
|
||||
"jest": "^29.6.3",
|
||||
"prettier": "2.8.8",
|
||||
"react-native-clean-project": "^4.0.3",
|
||||
|
||||
+32
-13
@@ -621,6 +621,7 @@ export const SendScreen = observer(function SendScreen({ route }: Props) {
|
||||
const syncStateListenerRef = useRef<((r: SyncStateTaskResult) => void) | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Clean up early if no transactionId
|
||||
if (!transactionId) {
|
||||
if (syncStateListenerRef.current) {
|
||||
EventEmitter.off(`ev_${SYNC_STATE_WITH_MINT_TASK}_result`, syncStateListenerRef.current);
|
||||
@@ -628,29 +629,47 @@ export const SendScreen = observer(function SendScreen({ route }: Props) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const eventName = `ev_${SYNC_STATE_WITH_MINT_TASK}_result`;
|
||||
|
||||
|
||||
// Remove any previous listener (in case deps changed)
|
||||
if (syncStateListenerRef.current) {
|
||||
EventEmitter.off(eventName, syncStateListenerRef.current);
|
||||
}
|
||||
|
||||
const oneTimeHandler = (result: SyncStateTaskResult) => {
|
||||
EventEmitter.off(eventName, oneTimeHandler);
|
||||
syncStateListenerRef.current = null;
|
||||
|
||||
const handler = (result: SyncStateTaskResult) => {
|
||||
handleSyncStateResult(result);
|
||||
|
||||
// "keep listening" for poller if our transaction is still pending
|
||||
const shouldStaySubscribed = (() => {
|
||||
const {transactionStateUpdates} = result
|
||||
|
||||
if(transactionStateUpdates.length === 0) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})();
|
||||
|
||||
// Only unsubscribe if the condition is NOT met
|
||||
if (!shouldStaySubscribed) {
|
||||
EventEmitter.off(eventName, handler);
|
||||
syncStateListenerRef.current = null;
|
||||
}
|
||||
// If shouldStaySubscribed === true → we keep the handler attached
|
||||
};
|
||||
|
||||
syncStateListenerRef.current = oneTimeHandler;
|
||||
EventEmitter.on(eventName, oneTimeHandler);
|
||||
|
||||
|
||||
syncStateListenerRef.current = handler;
|
||||
EventEmitter.on(eventName, handler);
|
||||
|
||||
// Cleanup on unmount or when transactionId/handleSyncStateResult changes
|
||||
return () => {
|
||||
if (syncStateListenerRef.current) {
|
||||
EventEmitter.off(eventName, syncStateListenerRef.current);
|
||||
syncStateListenerRef.current = null;
|
||||
EventEmitter.off(eventName, syncStateListenerRef.current);
|
||||
syncStateListenerRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [handleSyncStateResult])
|
||||
}, [transactionId, handleSyncStateResult]);
|
||||
|
||||
const toggleNostrDMModal = () => setIsNostrDMModalVisible(previousState => !previousState)
|
||||
const toggleProofSelectorModal = () => setIsProofSelectorModalVisible(previousState => !previousState)
|
||||
|
||||
Reference in New Issue
Block a user