Skip to content

Commit 74a4635

Browse files
committed
refactor(drag-drop): remove debug snapshot functionality from Android share intent handling
1 parent 3e1a837 commit 74a4635

12 files changed

Lines changed: 3 additions & 146 deletions

File tree

frontend/src/hooks/useDragDrop.ts

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { getCurrentWindow, invoke, openDialog } from '@/lib/platform-api'
22
import { processWebDataTransfer } from '@/lib/web-drag-drop'
33
import {
44
consumeShareIntent,
5-
debugShareSnapshot,
65
onShareReceived,
76
selectSendDocument,
87
selectSendFolder,
@@ -458,29 +457,6 @@ export function useDragDrop(
458457
// devices, so keep polling for several seconds rather than giving up early.
459458
const retryDelaysMs = [400, 1000, 2000, 3500, 5500, 8000]
460459

461-
// Temporary diagnostic: if we still haven't consumed anything by the time
462-
// retries run out, show what the native side actually saw on-screen (no
463-
// adb/chrome://inspect required to see this).
464-
const reportIfUnresolved = async () => {
465-
if (disposed || settled) return
466-
const snapshot = await debugShareSnapshot()
467-
if (disposed || settled || !snapshot) return
468-
if (snapshot.action !== 'android.intent.action.SEND') return
469-
showAlert(
470-
'Share debug',
471-
[
472-
`action=${snapshot.action}`,
473-
`type=${snapshot.type}`,
474-
`hasStream=${snapshot.hasStream}`,
475-
`hasClipData=${snapshot.hasClipData}`,
476-
`dataString=${snapshot.dataString}`,
477-
`extractedUri=${snapshot.extractedUri}`,
478-
`pendingUriPresent=${snapshot.pendingUriPresent}`,
479-
].join(' | '),
480-
'info'
481-
)
482-
}
483-
484460
const run = async () => {
485461
if (disposed || settled) return
486462
const consumed = await consumeAndroidShareRef.current()
@@ -504,12 +480,6 @@ export function useDragDrop(
504480
for (const delay of retryDelaysMs) {
505481
retryTimers.push(window.setTimeout(() => void run(), delay))
506482
}
507-
retryTimers.push(
508-
window.setTimeout(
509-
() => void reportIfUnresolved(),
510-
retryDelaysMs[retryDelaysMs.length - 1] + 500
511-
)
512-
)
513483
}
514484

515485
void setup()
@@ -521,7 +491,7 @@ export function useDragDrop(
521491
window.clearTimeout(id)
522492
}
523493
}
524-
}, [showAlert])
494+
}, [])
525495

526496
return {
527497
isDragActive,

frontend/src/plugins/nativeUtils.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -156,33 +156,6 @@ export async function consumeShareIntent(
156156
return new FileSelectedHandler(String(channel.id))
157157
}
158158

159-
export type ShareDebugSnapshot = {
160-
action: string | null
161-
type: string | null
162-
hasStream: boolean
163-
hasClipData: boolean
164-
dataString: string | null
165-
extractedUri: string | null
166-
pendingUriPresent: boolean
167-
}
168-
169-
/**
170-
* Temporary diagnostic: reports what the native plugin currently sees for the
171-
* launching/current Android intent. Lets us see share-intent state directly in
172-
* the app UI when adb/chrome://inspect logs aren't available.
173-
*/
174-
export async function debugShareSnapshot(): Promise<ShareDebugSnapshot | null> {
175-
if (!IS_TAURI) return null
176-
try {
177-
return await invoke<ShareDebugSnapshot>(
178-
'plugin:native-utils|debug_share_snapshot'
179-
)
180-
} catch (error) {
181-
console.error('[ShareIntent] debugShareSnapshot failed:', error)
182-
return null
183-
}
184-
}
185-
186159
/** Fired when a share arrives while the app is already open. */
187160
export async function onShareReceived(
188161
handler: () => void

src-tauri/plugins/tauri-plugin-native-utils/android/src/main/java/com/altsendme/plugin/native_utils/NativeUtils.kt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,6 @@ class NativeUtils(private val activity: Activity) : Plugin(activity) {
9595
this::handleSendSelection.name
9696
)
9797

98-
/**
99-
* Temporary diagnostic command — reports what the plugin currently sees for the
100-
* launching/current intent, so the state can be shown directly in the app UI when
101-
* device logs (adb/chrome://inspect) aren't available for debugging.
102-
*/
103-
@Command
104-
fun debug_share_snapshot(invoke: Invoke) {
105-
val intent = activity.intent
106-
val extractedUri = intent?.let { extractShareUri(it) }
107-
invoke.resolveObject(
108-
JSObject().apply {
109-
put("action", intent?.action)
110-
put("type", intent?.type)
111-
put("hasStream", intent?.hasExtra(Intent.EXTRA_STREAM) == true)
112-
put("hasClipData", intent?.clipData != null)
113-
put("dataString", intent?.dataString)
114-
put("extractedUri", extractedUri?.toString())
115-
put("pendingUriPresent", pendingShareUri.get() != null)
116-
}
117-
)
118-
}
119-
12098
@Command
12199
fun consume_share_intent(invoke: Invoke) {
122100
val args = invoke.parseArgs(SelectorArgs::class.java)

src-tauri/plugins/tauri-plugin-native-utils/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const COMMANDS: &[&str] = &[
33
"select_send_document",
44
"select_send_folder",
55
"consume_share_intent",
6-
"debug_share_snapshot",
76
"cancel_job",
87
"export_to_tree",
98
"open_download_folder",

src-tauri/plugins/tauri-plugin-native-utils/permissions/autogenerated/commands/debug_share_snapshot.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

src-tauri/plugins/tauri-plugin-native-utils/permissions/default.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ permissions = [
55
"allow-select-send-document",
66
"allow-select-send-folder",
77
"allow-consume-share-intent",
8-
"allow-debug-share-snapshot",
98
"allow-cancel-job",
109
"allow-export-to-tree",
1110
"allow-open-download-folder"

src-tauri/plugins/tauri-plugin-native-utils/permissions/schemas/schema.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,6 @@
318318
"const": "deny-consume-share-intent",
319319
"markdownDescription": "Denies the consume_share_intent command without any pre-configured scope."
320320
},
321-
{
322-
"description": "Enables the debug_share_snapshot command without any pre-configured scope.",
323-
"type": "string",
324-
"const": "allow-debug-share-snapshot",
325-
"markdownDescription": "Enables the debug_share_snapshot command without any pre-configured scope."
326-
},
327-
{
328-
"description": "Denies the debug_share_snapshot command without any pre-configured scope.",
329-
"type": "string",
330-
"const": "deny-debug-share-snapshot",
331-
"markdownDescription": "Denies the debug_share_snapshot command without any pre-configured scope."
332-
},
333321
{
334322
"description": "Enables the export_to_tree command without any pre-configured scope.",
335323
"type": "string",
@@ -391,10 +379,10 @@
391379
"markdownDescription": "Denies the select_send_folder command without any pre-configured scope."
392380
},
393381
{
394-
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-select-download-folder`\n- `allow-select-send-document`\n- `allow-select-send-folder`\n- `allow-consume-share-intent`\n- `allow-debug-share-snapshot`\n- `allow-cancel-job`\n- `allow-export-to-tree`\n- `allow-open-download-folder`",
382+
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-select-download-folder`\n- `allow-select-send-document`\n- `allow-select-send-folder`\n- `allow-consume-share-intent`\n- `allow-cancel-job`\n- `allow-export-to-tree`\n- `allow-open-download-folder`",
395383
"type": "string",
396384
"const": "default",
397-
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-select-download-folder`\n- `allow-select-send-document`\n- `allow-select-send-folder`\n- `allow-consume-share-intent`\n- `allow-debug-share-snapshot`\n- `allow-cancel-job`\n- `allow-export-to-tree`\n- `allow-open-download-folder`"
385+
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-select-download-folder`\n- `allow-select-send-document`\n- `allow-select-send-folder`\n- `allow-consume-share-intent`\n- `allow-cancel-job`\n- `allow-export-to-tree`\n- `allow-open-download-folder`"
398386
}
399387
]
400388
}

src-tauri/plugins/tauri-plugin-native-utils/src/commands.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ pub(crate) async fn consume_share_intent<R: Runtime>(
3636
app.native_utils().consume_share_intent(channel)
3737
}
3838

39-
#[command]
40-
pub(crate) async fn debug_share_snapshot<R: Runtime>(
41-
app: AppHandle<R>,
42-
) -> Result<ShareDebugSnapshot> {
43-
app.native_utils().debug_share_snapshot()
44-
}
45-
4639
#[command]
4740
pub(crate) async fn cancel_job<R: Runtime>(
4841
app: tauri::AppHandle<R>,

src-tauri/plugins/tauri-plugin-native-utils/src/desktop.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<R: Runtime> NativeUtils<R> {
3737
}
3838
}
3939

40-
impl<R: Runtime> NativeUtils<R> {
41-
pub fn debug_share_snapshot(&self) -> crate::Result<ShareDebugSnapshot> {
42-
Ok(ShareDebugSnapshot::default())
43-
}
44-
}
45-
4640
impl<R: Runtime> NativeUtils<R> {
4741
pub fn cancel_job(&self, _: AsyncJob) -> crate::Result<()> {
4842
Err(crate::Error::UnsupportedPlafrormError)

src-tauri/plugins/tauri-plugin-native-utils/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
4040
commands::select_send_document,
4141
commands::select_send_folder,
4242
commands::consume_share_intent,
43-
commands::debug_share_snapshot,
4443
commands::cancel_job,
4544
commands::export_to_tree,
4645
commands::open_download_folder,

0 commit comments

Comments
 (0)