Skip to content

Commit b2826d4

Browse files
committed
feat: introduce webxdc.isAppSender and webxdc.isBroadcast
This allows apps to behave differently, dependeing on the sending context.
1 parent 0e266f6 commit b2826d4

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

src-docs/spec/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [1.4] - 2026-04-16
4+
5+
### New APIs
6+
7+
- add `webxdc.isAppSender` and `webxdc.isBroadcast` to allow apps to determine
8+
their role and if they are in a broadcast chat
9+
310
## [1.3] - 2026-02-11
411

512
### Other changes

src-docs/spec/messenger.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ When starting a web view for a webxdc app to run, messenger implementors
5454

5555
- MUST support `<meta name="viewport" ...>` is useful especially as webviews from different platforms have different defaults
5656

57+
- MUST support `window.webxdc.isAppSender` and `window.webxdc.isBroadcast`
58+
to allow apps to determine their role and if they are in a broadcast chat.
59+
5760
- MUST support `<input type="file">` to allow importing of files;
5861
see [`sendToChat()`](../spec/sendToChat.md) for a way to export files.
5962

src-docs/spec/selfAddr_and_selfName.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ Note that `selfAddr`
3232
- should not be shown in the user interface of the webxdc application
3333
(use `selfName` instead).
3434

35+
## isAppSender
36+
37+
```js
38+
window.webxdc.isAppSender
39+
```
40+
41+
`isAppSender` is a boolean value that is `true` if the local user is the one
42+
who initially shared the webxdc application in the chat.
43+
If it is `false`, the user is a receiver.
44+
45+
## isBroadcast
46+
47+
```js
48+
window.webxdc.isBroadcast
49+
```
50+
51+
`isBroadcast` is a boolean value that is `true` if the webxdc
52+
application is shared in a broadcast chat context.
3553

3654

3755
## Example using selfAddr and selfName

src-docs/webxdc.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ interface Webxdc<T> {
7272
selfAddr: string;
7373
/** Returns the peer's own name. This is name chosen by the user in their settings, if there is nothing set, that defaults to the peer's address. */
7474
selfName: string;
75+
/** True if the current user is the sender of this webxdc app. */
76+
isAppSender: boolean;
77+
/** True if the current user is in a broadcast chat. */
78+
isBroadcast: boolean;
7579
/**
7680
* set a listener for new status updates.
7781
* The "serial" specifies the last serial that you know about (defaults to 0).

0 commit comments

Comments
 (0)