Docs: improve docs

This commit is contained in:
Pieter Vander Vennet 2025-04-27 02:00:53 +02:00
parent b5557088e9
commit 82c77de2ea
2 changed files with 13 additions and 4 deletions

View file

@ -619,7 +619,7 @@ export class OsmConnection {
return
}
const tokenPromise = AndroidPolyfill.requestLoginCodes()
console.trace("Opening login page")
console.trace("Opening login page for android")
await AndroidPolyfill.openLoginPage()
const token = await tokenPromise
console.log("Got login token!", token)

View file

@ -4,7 +4,6 @@
*/
import { registerPlugin } from "@capacitor/core"
import { Store, UIEventSource } from "../UIEventSource"
import { OsmConnection } from "../Osm/OsmConnection"
export interface DatabridgePlugin {
request<T extends string | object = string | object>(options: {
@ -70,9 +69,19 @@ export class AndroidPolyfill {
AndroidPolyfill.backfillGeolocation(AndroidPolyfill.databridgePlugin)
}
public static async openLoginPage() {
await DatabridgePluginSingleton.request<{ oauth_token: string }>({ key: "open:login" })
/**
* Actually opens the login page
* Note that the actual token is handled by requestLoginCodes
*/
public static async openLoginPage(): Promise<void> {
await DatabridgePluginSingleton.request({ key: "open:login" })
}
/**
* Installs a callback that might eventually get the login token.
* It requests the login codes to the shell, not to the user.
* This method can be called without bothering the user.
*/
public static async requestLoginCodes() {
const result = await DatabridgePluginSingleton.request<{ oauth_token: string }>({
key: "request:login",