Skip to content

android: device pins/favorites and match iOS long push menu - #856

Open
hiimtmac wants to merge 2 commits into
mainfrom
tm/support-local-pins
Open

hiimtmac wants to merge 2 commits into
mainfrom
tm/support-local-pins

Conversation

@hiimtmac

@hiimtmac hiimtmac commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Adds support for device pinning - from device list and from peer detail
Match iOS long push menu - ipv4/ipv6/magic DNS, update icon and reorder

Fixes https://github.com/tailscale/corp/issues/47581
Fixes https://github.com/tailscale/corp/issues/47582

Screen_Recording_20260904_110411.mp4

@hiimtmac
hiimtmac requested review from barnstar and kari-ts September 4, 2026 16:09
@hiimtmac
hiimtmac force-pushed the tm/support-local-pins branch from c59f7b6 to fd845fe Compare September 9, 2026 20:36
Comment thread android/src/main/java/com/tailscale/ipn/ui/notifier/FavoritesManager.kt Outdated
Comment thread android/src/main/java/com/tailscale/ipn/ui/notifier/FavoritesManager.kt Outdated
@hiimtmac
hiimtmac force-pushed the tm/support-local-pins branch from fd845fe to 8c53571 Compare September 11, 2026 14:45
@hiimtmac
hiimtmac requested a review from kari-ts September 11, 2026 14:51
@hiimtmac
hiimtmac force-pushed the tm/support-local-pins branch from 8c53571 to ed0eaf8 Compare September 11, 2026 15:14

@barnstar barnstar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - just one small issue with the write serialization. I think we should also add the long press gesture the the search results if that's possible - though we can do that in a follow-up.

revert = null
_writing.value = true

val result = suspendCancellableCoroutine { cont ->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tangential to this PR, but the client API functions not being suspend fun's is maybe something we should consider changing to avoid the use of continuations here.

}

private suspend fun write(request: FavoritesRequest) {
val snapshot = revert

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing a try-catch in case the the suspendCancellableCoroutine is cancelled... But it may make more sense to track the job and cancel that. Or just wrap the contents of write() in a mutex.

private var writeJob: Job? = null

fun enqueueWrite(request: FavoritesRequest) {
    writeJob?.cancel() 
    writeJob = viewModelScope.launch {
        write(request)
    }
}

private suspend fun write(request: FavoritesRequest) {
    val snapshot = _favorites.value 
    val profile = currentProfile
    
    _writing.value = true

    try {
        val result = suspendCancellableCoroutine { cont -> 
            val call = client.setFavorites(request) { cont.resume(it) }
        }

        if (currentProfile != profile) return

        result.onFailure {
            TSLog.e(TAG, "Error writing favorites: ${it.message}")
            _favorites.value = snapshot
        }
    } finally {
        _writing.value = false 
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants