plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

[bug] plugin-geolocation in watchPosition

Open Bet4Arrio opened this issue 7 months ago • 1 comments

using the plugin-geolocation in android with solid, I had a problem with the watchPosition function, that never returns the channel id. in the Js code I Find that thea wait in in the invoke function never ends.


async function watchPosition(options: PositionOptions, cb: (location: Position | null, error?: string) => void) {
    const channel = new core.Channel();
    channel.onmessage = (message) => {
        if (typeof message === 'string') {
            cb(null, message);
        }
        else{
            cb(message);
        }
    };
    await core.invoke('plugin:geolocation|watch_position', {
        options,
        channel
    });
    return channel.id;
}

so I """"fix It"""" just removing the await of the invoke function, and works well, but I thing the problem in the rust code.


async function watchPosition(options: PositionOptions, cb: (location: Position | null, error?: string) => void) {
    const channel = new core.Channel();
    channel.onmessage = (message) => {
        if (typeof message === 'string') {
            cb(null, message);
        }
         else{
            cb(message);
        }
    };
    core.invoke('plugin:geolocation|watch_position', {
        options,
        channel
    });
    return channel.id;
}

Bet4Arrio avatar May 06 '25 15:05 Bet4Arrio

At first glance it looks like the issue is the kotlin code because it never calls invoke.resolve() like the other commands. Since it stores the invoke call for later this may be intentional idk (the missing resolve call, not the never returning command). I'm only on my phone so I can't really see the intentions in the code.

Thanks for the report btw

FabianLars avatar May 06 '25 18:05 FabianLars