Skip to content

Commit

Permalink
fix: prevent crash when closing transmission on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Ray committed Jul 29, 2024
1 parent 97d88cb commit e678329
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion apps/app/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ if (Platform.OS === 'web') {
require('@tamagui/core/reset.css')
}

console.log('initApp')
initApp()

polyfillWebCrypto()
1 change: 0 additions & 1 deletion apps/app/lib/lifecycle.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const handleEvents = async ({ type, detail }: Event) => {

// Exit
if (type === EventType.ACTION_PRESS && detail.pressAction?.id === 'exit') {
console.log('handleEvents exit')
quitApp()
}
}
Expand Down
7 changes: 4 additions & 3 deletions apps/app/lib/transmission.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const PUBLIC_DOWNLOAD_DIR =
export const PUBLIC_DOCUMENTS_DIR =
RNFS.ExternalStorageDirectoryPath + '/Documents'

let transmission: Transmission
let transmission: Transmission | null

export const init = async () => {
transmission = new Transmission(
Expand Down Expand Up @@ -51,11 +51,12 @@ export const init = async () => {
}

export const request = (...args) => {
return transmission.request(...args)
return transmission?.request(...args)
}

export const close = () => {
return transmission.close()
transmission?.close()
transmission = null
}

export { transmission }

0 comments on commit e678329

Please sign in to comment.