From cb87bf35a963d47cdd0827d673daba65e1a3f87e Mon Sep 17 00:00:00 2001
From: Ayo
Date: Sat, 26 Jul 2025 21:32:08 +0200
Subject: [PATCH 1/2] chore: Update readme project name
---
README.md | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 3d90a5da..20cca13d 100644
--- a/README.md
+++ b/README.md
@@ -4,10 +4,9 @@
-Elk alpha
-
+Yolk
-A nimble Mastodon web client
+Yolk is cusom fork of Elk, a nimble Mastodon client
--
2.45.2
From b854b43228cadb3d4717902eb7975f0603859a33 Mon Sep 17 00:00:00 2001
From: Ayo
Date: Sun, 23 Nov 2025 18:41:49 +0100
Subject: [PATCH 2/2] feat: check user session before subscribing to streaming
---
.../timeline/TimelineNotifications.vue | 7 +-
app/composables/masto/masto.ts | 92 +++++++++----------
2 files changed, 47 insertions(+), 52 deletions(-)
diff --git a/app/components/timeline/TimelineNotifications.vue b/app/components/timeline/TimelineNotifications.vue
index 035446e9..548e7020 100644
--- a/app/components/timeline/TimelineNotifications.vue
+++ b/app/components/timeline/TimelineNotifications.vue
@@ -14,11 +14,8 @@ const options = { limit: 30, types: filter ? [filter] : [] }
// Default limit is 20 notifications, and servers are normally caped to 30
const paginator = useMastoClient().v1.notifications.list(options)
-// streaming requires user session
-let stream: Ref
-if (currentUser.value !== undefined)
- // @ts-expect-error Type error should be fixed with the following PR to masto.js: https://github.com/neet/masto.js/pull/1355
- stream = useStreaming(client => client.user.notification.subscribe())
+// @ts-expect-error Type error should be fixed with the following PR to masto.js: https://github.com/neet/masto.js/pull/1355
+const stream = useStreaming(client => client.user.notification.subscribe())
lastAccessedNotificationRoute.value = route.path.replace(/\/notifications\/?/, '')
diff --git a/app/composables/masto/masto.ts b/app/composables/masto/masto.ts
index 3a217519..5b90ccc9 100644
--- a/app/composables/masto/masto.ts
+++ b/app/composables/masto/masto.ts
@@ -26,59 +26,57 @@ export function mastoLogin(masto: ElkMasto, user: Pick mastodon.streaming.Client | undefined
+ const createStreamingClient = (streamingApiUrl: string | undefined) => {
+ // Only create the streaming client when there is a user session
+ return streamingApiUrl && currentUser.value
+ ? createStreamingAPIClient({ streamingApiUrl, accessToken, implementation: globalThis.WebSocket })
+ : undefined
+ }
+ const streamingApiUrl = instance?.configuration?.urls?.streaming
masto.client.value = createRestAPIClient({ url, accessToken })
+ masto.streamingClient.value = createStreamingClient(streamingApiUrl)
- if (currentUser.value !== undefined) {
- createStreamingClient = (streamingApiUrl: string | undefined) => {
- return streamingApiUrl ? createStreamingAPIClient({ streamingApiUrl, accessToken, implementation: globalThis.WebSocket }) : undefined
+ // Refetch instance info in the background on login
+ masto.client.value.v2.instance.fetch().catch(error => new Promise((resolve, reject) => {
+ if (error instanceof MastoHttpError && error.statusCode === 404) {
+ return masto.client.value.v1.instance.fetch().then((newInstance) => {
+ console.warn(`Instance ${server} on version ${newInstance.version} does not support "GET /api/v2/instance" API, try converting to v2 instance... expect some errors`)
+ const v2Instance = {
+ ...newInstance,
+ domain: newInstance.uri,
+ sourceUrl: '',
+ usage: {
+ users: {
+ activeMonth: 0,
+ },
+ },
+ icon: [],
+ apiVersions: {
+ mastodon: newInstance.version,
+ },
+ contact: {
+ email: newInstance.email,
+ },
+ configuration: {
+ ...(newInstance.configuration ?? {}),
+ urls: {
+ streaming: newInstance.urls.streamingApi,
+ },
+ },
+ } as unknown as mastodon.v2.Instance
+ return resolve(v2Instance)
+ }).catch(reject)
}
- const streamingApiUrl = instance?.configuration?.urls?.streaming
- masto.streamingClient.value = createStreamingClient(streamingApiUrl)
+ return reject(error)
+ })).then((newInstance) => {
+ Object.assign(instance, newInstance)
+ if (newInstance.configuration.urls.streaming !== streamingApiUrl)
+ masto.streamingClient.value = createStreamingClient(newInstance.configuration.urls.streaming)
- // Refetch instance info in the background on login
- masto.client.value.v2.instance.fetch().catch(error => new Promise((resolve, reject) => {
- if (error instanceof MastoHttpError && error.statusCode === 404) {
- return masto.client.value.v1.instance.fetch().then((newInstance) => {
- console.warn(`Instance ${server} on version ${newInstance.version} does not support "GET /api/v2/instance" API, try converting to v2 instance... expect some errors`)
- const v2Instance = {
- ...newInstance,
- domain: newInstance.uri,
- sourceUrl: '',
- usage: {
- users: {
- activeMonth: 0,
- },
- },
- icon: [],
- apiVersions: {
- mastodon: newInstance.version,
- },
- contact: {
- email: newInstance.email,
- },
- configuration: {
- ...(newInstance.configuration ?? {}),
- urls: {
- streaming: newInstance.urls.streamingApi,
- },
- },
- } as unknown as mastodon.v2.Instance
- return resolve(v2Instance)
- }).catch(reject)
- }
-
- return reject(error)
- })).then((newInstance) => {
- Object.assign(instance, newInstance)
- if (newInstance.configuration.urls.streaming !== streamingApiUrl)
- masto.streamingClient.value = createStreamingClient(newInstance.configuration.urls.streaming)
-
- instanceStorage.value[server] = newInstance
- })
- }
+ instanceStorage.value[server] = newInstance
+ })
return instance
}
--
2.45.2