From 3a577df9ab1c635c50982eef787040a006536e76 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 3 Apr 2023 10:10:12 -0700 Subject: [PATCH 01/72] dev24 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3fe277aea9..077def577c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calckey", - "version": "13.2.0-dev23", + "version": "13.2.0-dev24", "codename": "aqua", "repository": { "type": "git", From 03e52e58376943a00535cbd96fcf1070f5cd9bdb Mon Sep 17 00:00:00 2001 From: Kainoa Kanter Date: Mon, 3 Apr 2023 17:17:08 +0000 Subject: [PATCH 02/72] chore: update patrons --- patrons.json | 1 + 1 file changed, 1 insertion(+) diff --git a/patrons.json b/patrons.json index ea481f6fd7..9174519833 100644 --- a/patrons.json +++ b/patrons.json @@ -21,6 +21,7 @@ "@trapezial@calckey.jp", "@unattributed@calckey.social", "@cody@mk.codingneko.com", + "@kate@blahaj.zone", "Interkosmos Link" ] } From 4478468256777c8e7510038bdcb4f9c106f49481 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 3 Apr 2023 16:02:09 -0700 Subject: [PATCH 03/72] fix: :bug: go to last timeline selected --- packages/client/src/pages/timeline.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/pages/timeline.vue b/packages/client/src/pages/timeline.vue index 5a5e51ec61..9c326ad05e 100644 --- a/packages/client/src/pages/timeline.vue +++ b/packages/client/src/pages/timeline.vue @@ -336,7 +336,7 @@ function syncSlide(index) { } onMounted(() => { - syncSlide(timelines.indexOf(swiperRef.activeIndex)); + syncSlide(timelines.indexOf(defaultStore.state.tl?.src || swiperRef.activeIndex)); }); From daba80177a7bade502b9acc32828f6b89337bba0 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 3 Apr 2023 20:36:59 -0700 Subject: [PATCH 04/72] feat: :sparkles: push notifs button Co-authored-by: Tamania --- locales/en-US.yml | 1 + locales/ja-JP.yml | 1 + ...6634-whetherPushNotifyToSendReadMessage.js | 11 ++ .../src/models/entities/sw-subscription.ts | 5 + packages/backend/src/server/api/endpoints.ts | 4 + .../src/server/api/endpoints/sw/register.ts | 26 ++- .../api/endpoints/sw/show-registration.ts | 55 ++++++ .../src/server/api/endpoints/sw/unregister.ts | 6 +- .../api/endpoints/sw/update-registration.ts | 44 +++++ .../backend/src/services/push-notification.ts | 7 + .../MkPushNotificationAllowButton.vue | 171 ++++++++++++++++++ .../src/components/MkTutorialDialog.vue | 2 + .../src/pages/settings/notifications.vue | 32 ++++ packages/client/src/scripts/initialize-sw.ts | 56 ------ 14 files changed, 359 insertions(+), 62 deletions(-) create mode 100644 packages/backend/migration/1669138716634-whetherPushNotifyToSendReadMessage.js create mode 100644 packages/backend/src/server/api/endpoints/sw/show-registration.ts create mode 100644 packages/backend/src/server/api/endpoints/sw/update-registration.ts create mode 100644 packages/client/src/components/MkPushNotificationAllowButton.vue diff --git a/locales/en-US.yml b/locales/en-US.yml index f4913e9041..0a0f86a106 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -12,6 +12,7 @@ fetchingAsApObject: "Fetching from the Fediverse" ok: "OK" gotIt: "Got it!" cancel: "Cancel" +noThankYou: "No thank you" enterUsername: "Enter username" renotedBy: "Boosted by {user}" noNotes: "No posts" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 64d804928e..29e2416222 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -12,6 +12,7 @@ fetchingAsApObject: "連合宇宙から取得中" ok: "OK" gotIt: "わかった!" cancel: "キャンセル" +noThankYou: "やめておく" enterUsername: "ユーザー名を入力" renotedBy: "{user}がブースト" noNotes: "投稿はありません" diff --git a/packages/backend/migration/1669138716634-whetherPushNotifyToSendReadMessage.js b/packages/backend/migration/1669138716634-whetherPushNotifyToSendReadMessage.js new file mode 100644 index 0000000000..2265b00617 --- /dev/null +++ b/packages/backend/migration/1669138716634-whetherPushNotifyToSendReadMessage.js @@ -0,0 +1,11 @@ +export class whetherPushNotifyToSendReadMessage1669138716634 { + name = 'whetherPushNotifyToSendReadMessage1669138716634' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "sw_subscription" ADD "sendReadMessage" boolean NOT NULL DEFAULT false`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "sw_subscription" DROP COLUMN "sendReadMessage"`); + } +} diff --git a/packages/backend/src/models/entities/sw-subscription.ts b/packages/backend/src/models/entities/sw-subscription.ts index 26891c1ce7..8f18688eab 100644 --- a/packages/backend/src/models/entities/sw-subscription.ts +++ b/packages/backend/src/models/entities/sw-subscription.ts @@ -41,4 +41,9 @@ export class SwSubscription { length: 128, }) public publickey: string; + + @Column('boolean', { + default: false, + }) + public sendReadMessage: boolean; } diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 920f871995..57a3ce4dc2 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -290,6 +290,8 @@ import * as ep___resetDb from "./endpoints/reset-db.js"; import * as ep___resetPassword from "./endpoints/reset-password.js"; import * as ep___serverInfo from "./endpoints/server-info.js"; import * as ep___stats from "./endpoints/stats.js"; +import * as ep___sw_show_registration from './endpoints/sw/show-registration.js'; +import * as ep___sw_update_registration from './endpoints/sw/update-registration.js'; import * as ep___sw_register from "./endpoints/sw/register.js"; import * as ep___sw_unregister from "./endpoints/sw/unregister.js"; import * as ep___test from "./endpoints/test.js"; @@ -637,6 +639,8 @@ const eps = [ ["stats", ep___stats], ["sw/register", ep___sw_register], ["sw/unregister", ep___sw_unregister], + ['sw/show-registration', ep___sw_show_registration], + ['sw/update-registration', ep___sw_update_registration], ["test", ep___test], ["username/available", ep___username_available], ["users", ep___users], diff --git a/packages/backend/src/server/api/endpoints/sw/register.ts b/packages/backend/src/server/api/endpoints/sw/register.ts index 7218b0d50a..d2b805d974 100644 --- a/packages/backend/src/server/api/endpoints/sw/register.ts +++ b/packages/backend/src/server/api/endpoints/sw/register.ts @@ -26,6 +26,18 @@ export const meta = { optional: false, nullable: true, }, + userId: { + type: 'string', + optional: false, nullable: false, + }, + endpoint: { + type: 'string', + optional: false, nullable: false, + }, + sendReadMessage: { + type: 'boolean', + optional: false, nullable: false, + }, }, }, } as const; @@ -36,14 +48,15 @@ export const paramDef = { endpoint: { type: "string" }, auth: { type: "string" }, publickey: { type: "string" }, + sendReadMessage: { type: 'boolean', default: false }, }, required: ["endpoint", "auth", "publickey"], } as const; -export default define(meta, paramDef, async (ps, user) => { +export default define(meta, paramDef, async (ps, me) => { // if already subscribed const exist = await SwSubscriptions.findOneBy({ - userId: user.id, + userId: me.id, endpoint: ps.endpoint, auth: ps.auth, publickey: ps.publickey, @@ -55,20 +68,27 @@ export default define(meta, paramDef, async (ps, user) => { return { state: "already-subscribed" as const, key: instance.swPublicKey, + userId: me.id, + endpoint: exist.endpoint, + sendReadMessage: exist.sendReadMessage, }; } await SwSubscriptions.insert({ id: genId(), createdAt: new Date(), - userId: user.id, + userId: me.id, endpoint: ps.endpoint, auth: ps.auth, publickey: ps.publickey, + sendReadMessage: ps.sendReadMessage, }); return { state: "subscribed" as const, key: instance.swPublicKey, + userId: me.id, + endpoint: ps.endpoint, + sendReadMessage: ps.sendReadMessage, }; }); diff --git a/packages/backend/src/server/api/endpoints/sw/show-registration.ts b/packages/backend/src/server/api/endpoints/sw/show-registration.ts new file mode 100644 index 0000000000..25eb53f527 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/sw/show-registration.ts @@ -0,0 +1,55 @@ +import { SwSubscriptions } from '@/models/index.js'; +import define from "../../define.js"; + +export const meta = { + tags: ['account'], + + requireCredential: true, + + description: 'Check push notification registration exists.', + + res: { + type: 'object', + optional: false, nullable: true, + properties: { + userId: { + type: 'string', + optional: false, nullable: false, + }, + endpoint: { + type: 'string', + optional: false, nullable: false, + }, + sendReadMessage: { + type: 'boolean', + optional: false, nullable: false, + }, + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + endpoint: { type: 'string' }, + }, + required: ['endpoint'], +} as const; + +// eslint-disable-next-line import/no-default-export +export default define(meta, paramDef, async (ps, me) => { + const exist = await SwSubscriptions.findOneBy({ + userId: me.id, + endpoint: ps.endpoint, + }); + + if (exist != null) { + return { + userId: exist.userId, + endpoint: exist.endpoint, + sendReadMessage: exist.sendReadMessage, + }; + } + + return null; +}); diff --git a/packages/backend/src/server/api/endpoints/sw/unregister.ts b/packages/backend/src/server/api/endpoints/sw/unregister.ts index b025630e4b..e2a40f51cb 100644 --- a/packages/backend/src/server/api/endpoints/sw/unregister.ts +++ b/packages/backend/src/server/api/endpoints/sw/unregister.ts @@ -4,7 +4,7 @@ import define from "../../define.js"; export const meta = { tags: ["account"], - requireCredential: true, + requireCredential: false, description: "Unregister from receiving push notifications.", } as const; @@ -17,9 +17,9 @@ export const paramDef = { required: ["endpoint"], } as const; -export default define(meta, paramDef, async (ps, user) => { +export default define(meta, paramDef, async (ps, me) => { await SwSubscriptions.delete({ - userId: user.id, + ...(me ? { userId: me.id } : {}), endpoint: ps.endpoint, }); }); diff --git a/packages/backend/src/server/api/endpoints/sw/update-registration.ts b/packages/backend/src/server/api/endpoints/sw/update-registration.ts new file mode 100644 index 0000000000..0b0a56d499 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/sw/update-registration.ts @@ -0,0 +1,44 @@ +import { SwSubscriptions } from "@/models/index.js"; +import define from "../../define.js"; + +export const meta = { + tags: ["account"], + + requireCredential: true, + + description: "Unregister from receiving push notifications.", +} as const; + +export const paramDef = { + type: "object", + properties: { + endpoint: { type: "string" }, + sendReadMessage: { type: 'boolean' }, + }, + required: ["endpoint"], +} as const; + +export default define(meta, paramDef, async (ps, me) => { + const swSubscription = await SwSubscriptions.findOneBy({ + userId: me.id, + endpoint: ps.endpoint, + }); + + if (swSubscription === null) { + throw new Error("No such registration"); + } + + if (ps.sendReadMessage !== undefined) { + swSubscription.sendReadMessage = ps.sendReadMessage; + } + + await SwSubscriptions.update(swSubscription.id, { + sendReadMessage: swSubscription.sendReadMessage, + }); + + return { + userId: swSubscription.userId, + endpoint: swSubscription.endpoint, + sendReadMessage: swSubscription.sendReadMessage, + }; +}); diff --git a/packages/backend/src/services/push-notification.ts b/packages/backend/src/services/push-notification.ts index 0e51ad9675..a3abaf769c 100644 --- a/packages/backend/src/services/push-notification.ts +++ b/packages/backend/src/services/push-notification.ts @@ -63,6 +63,13 @@ export async function pushNotification( }); for (const subscription of subscriptions) { + if ([ + 'readNotifications', + 'readAllNotifications', + 'readAllMessagingMessages', + 'readAllMessagingMessagesOfARoom', + ].includes(type) && !subscription.sendReadMessage) continue; + const pushSubscription = { endpoint: subscription.endpoint, keys: { diff --git a/packages/client/src/components/MkPushNotificationAllowButton.vue b/packages/client/src/components/MkPushNotificationAllowButton.vue new file mode 100644 index 0000000000..b98c814f24 --- /dev/null +++ b/packages/client/src/components/MkPushNotificationAllowButton.vue @@ -0,0 +1,171 @@ + + + diff --git a/packages/client/src/components/MkTutorialDialog.vue b/packages/client/src/components/MkTutorialDialog.vue index c077d3fc5f..77cc4de6fb 100644 --- a/packages/client/src/components/MkTutorialDialog.vue +++ b/packages/client/src/components/MkTutorialDialog.vue @@ -106,6 +106,7 @@

{{ i18n.ts._tutorial.step6_4 }}

+ @@ -122,6 +123,7 @@ import MkButton from '@/components/MkButton.vue'; import XFeaturedUsers from '@/pages/explore.users.vue'; import XPostForm from '@/components/MkPostForm.vue'; import MkSparkle from '@/components/MkSparkle.vue'; +import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue'; import { defaultStore } from '@/store'; import { i18n } from '@/i18n'; import { $i } from '@/account'; diff --git a/packages/client/src/pages/settings/notifications.vue b/packages/client/src/pages/settings/notifications.vue index b0bf970bca..586da9e154 100644 --- a/packages/client/src/pages/settings/notifications.vue +++ b/packages/client/src/pages/settings/notifications.vue @@ -6,6 +6,21 @@ {{ i18n.ts.markAsReadAllUnreadNotes }} {{ i18n.ts.markAsReadAllTalkMessages }} + + + +
+ + + + + +
+
@@ -19,6 +34,11 @@ import * as os from '@/os'; import { $i } from '@/account'; import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; +import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue'; + +let allowButton = $shallowRef>(); +let pushRegistrationInServer = $computed(() => allowButton?.pushRegistrationInServer); +let sendReadMessage = $computed(() => pushRegistrationInServer?.sendReadMessage || false); async function readAllUnreadNotes() { await os.api('i/read-all-unread-notes'); @@ -49,6 +69,18 @@ function configure() { }, 'closed'); } +function onChangeSendReadMessage(v: boolean) { + if (!pushRegistrationInServer) return; + + os.apiWithDialog('sw/update-registration', { + endpoint: pushRegistrationInServer.endpoint, + sendReadMessage: v, + }).then(res => { + if (!allowButton) return; + allowButton.pushRegistrationInServer = res; + }); +} + const headerActions = $computed(() => []); const headerTabs = $computed(() => []); diff --git a/packages/client/src/scripts/initialize-sw.ts b/packages/client/src/scripts/initialize-sw.ts index 74f0e9b446..737f86515a 100644 --- a/packages/client/src/scripts/initialize-sw.ts +++ b/packages/client/src/scripts/initialize-sw.ts @@ -1,6 +1,3 @@ -import { instance } from "@/instance"; -import { $i } from "@/account"; -import { api } from "@/os"; import { lang } from "@/config"; export async function initializeSw() { @@ -12,58 +9,5 @@ export async function initializeSw() { msg: "initialize", lang, }); - - if (instance.swPublickey && "PushManager" in window && $i && $i.token) { - // SEE: https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe#Parameters - registration.pushManager - .subscribe({ - userVisibleOnly: true, - applicationServerKey: urlBase64ToUint8Array(instance.swPublickey), - }) - .then((subscription) => { - function encode(buffer: ArrayBuffer | null) { - return btoa( - String.fromCharCode.apply(null, new Uint8Array(buffer)), - ); - } - - // Register - api("sw/register", { - endpoint: subscription.endpoint, - auth: encode(subscription.getKey("auth")), - publickey: encode(subscription.getKey("p256dh")), - }); - }) - // When subscribe failed - .catch(async (err: Error) => { - // 通知が許可されていなかったとき - if (err.name === "NotAllowedError") { - return; - } - - // 違うapplicationServerKey (または gcm_sender_id)のサブスクリプションが - // 既に存在していることが原因でエラーになった可能性があるので、 - // そのサブスクリプションを解除しておく - const subscription = await registration.pushManager.getSubscription(); - if (subscription) subscription.unsubscribe(); - }); - } }); } - -/** - * Convert the URL safe base64 string to a Uint8Array - * @param base64String base64 string - */ -function urlBase64ToUint8Array(base64String: string): Uint8Array { - const padding = "=".repeat((4 - (base64String.length % 4)) % 4); - const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/"); - - const rawData = window.atob(base64); - const outputArray = new Uint8Array(rawData.length); - - for (let i = 0; i < rawData.length; ++i) { - outputArray[i] = rawData.charCodeAt(i); - } - return outputArray; -} From caff11c91c2886c8926fd5e01ee5fd5a3a28e215 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 3 Apr 2023 20:37:07 -0700 Subject: [PATCH 05/72] dev25 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 077def577c..c937e64c3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calckey", - "version": "13.2.0-dev24", + "version": "13.2.0-dev25", "codename": "aqua", "repository": { "type": "git", From 461b0a578bed760fc27a4086404e695d3c01c108 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 3 Apr 2023 20:38:29 -0700 Subject: [PATCH 06/72] chore: pnpm 8.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c937e64c3c..8878ba67d6 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://codeberg.org/calckey/calckey.git" }, - "packageManager": "pnpm@8.1.0", + "packageManager": "pnpm@8.1.1", "private": true, "scripts": { "rebuild": "pnpm run clean && pnpm -r run build && pnpm run gulp", From a844216b30be8413bd4d392cea4bc41d74624310 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 3 Apr 2023 20:44:52 -0700 Subject: [PATCH 07/72] locales --- locales/en-US.yml | 7 +++++++ locales/ja-JP.yml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/locales/en-US.yml b/locales/en-US.yml index 0a0f86a106..1bdf57faef 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -917,6 +917,13 @@ navbar: "Navigation bar" shuffle: "Shuffle" account: "Account" move: "Move" +pushNotification: "Push notifications" +subscribePushNotification: "Enable push notifications" +unsubscribePushNotification: "Disable push notifications" +pushNotificationAlreadySubscribed: "Push notifications are already enabled" +pushNotificationNotSupported: "Your browser or instance does not support push notifications" +sendPushNotificationReadMessage: "Delete push notifications once the relevant notifications or messages have been read" +sendPushNotificationReadMessageCaption: "A notification containing the text \"{emptyPushNotificationMessage}\" will be displayed for a short time. This may increase the battery usage of your device, if applicable." showAds: "Show ads" enterSendsMessage: "Press Return in Messaging to send message (off is Ctrl + Return)" adminCustomCssWarn: "This setting should only be used if you know what it does. Entering improper values may cause EVERYONE'S clients to stop functioning normally. Please ensure your CSS works properly by testing it in your user settings." diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 29e2416222..26971184c2 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -919,6 +919,13 @@ navbar: "ナビゲーションバー" shuffle: "シャッフル" account: "アカウント" move: "移動" +pushNotification: "プッシュ通知" +subscribePushNotification: "プッシュ通知を有効化" +unsubscribePushNotification: "プッシュ通知を停止する" +pushNotificationAlreadySubscribed: "プッシュ通知は有効です" +pushNotificationNotSupported: "ブラウザかサーバーがプッシュ通知に非対応" +sendPushNotificationReadMessage: "通知やメッセージが既読になったらプッシュ通知を削除する" +sendPushNotificationReadMessageCaption: "「{emptyPushNotificationMessage}」という通知が一瞬表示されるようになります。端末の電池消費量が増加する可能性があります。" adminCustomCssWarn: "この設定は、それが何をするものであるかを知っている場合のみ使用してください。不適切な値を入力すると、クライアントが正常に動作しなくなる可能性があります。ユーザー設定でCSSをテストし、正しく動作することを確認してください。" customMOTD: "カスタムMOTD(スプラッシュスクリーンメッセージ)" customMOTDDescription: "ユーザがページをロード/リロードするたびにランダムに表示される、改行で区切られたMOTD(スプラッシュスクリーン)用のカスタムメッセージ" From 006bfbd42ba3937f71dd8997315b2ea28add4fbc Mon Sep 17 00:00:00 2001 From: amybones Date: Tue, 4 Apr 2023 03:46:23 +0000 Subject: [PATCH 08/72] fix: toggling the blocking state from the instance-info admin view (#9809) Because the admin meta information was never loaded on this page, no amount of toggling the block or suspend sliders on the instance-info page (e.g. `https://calckey.example.com/instance-info/instance.tld`) will result in the instance actually being added to the blocklist. You could still do it from the bulk blocklist management page, but that can get unwieldy quickly if you just want to do a quick block of an instance. Co-authored-by: amy bones Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9809 Co-authored-by: amybones Co-committed-by: amybones --- .../server/api/endpoints/admin/update-meta.ts | 7 ++- packages/client/src/pages/instance-info.vue | 50 ++++++++++++++----- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index 28aac4a4d4..d3a39acd2d 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -209,7 +209,12 @@ export default define(meta, paramDef, async (ps, me) => { } if (Array.isArray(ps.blockedHosts)) { - set.blockedHosts = ps.blockedHosts.filter(Boolean); + let lastValue = ''; + set.blockedHosts = ps.blockedHosts.sort().filter(h => { + const lv = lastValue; + lastValue = h; + return h !== '' && h !== lv; + }); } if (ps.themeColor !== undefined) { diff --git a/packages/client/src/pages/instance-info.vue b/packages/client/src/pages/instance-info.vue index 15c9a7cd8b..f84e3b0147 100644 --- a/packages/client/src/pages/instance-info.vue +++ b/packages/client/src/pages/instance-info.vue @@ -35,8 +35,10 @@ - {{ i18n.ts.stopActivityDelivery }} - {{ i18n.ts.blockThisInstance }} + + {{ i18n.ts.stopActivityDelivery }} + {{ i18n.ts.blockThisInstance }} + Refresh metadata @@ -158,6 +160,13 @@ import 'swiper/scss'; import 'swiper/scss/virtual'; import { getProxiedImageUrlNullable } from '@/scripts/media-proxy'; +type AugmentedInstanceMetadata = misskey.entities.DetailedInstanceMetadata & { + blockedHosts: string[]; +}; +type AugmentedInstance = misskey.entities.Instance & { + isBlocked: boolean; +}; + const props = defineProps<{ host: string; }>(); @@ -168,8 +177,8 @@ let tab = $ref(tabs[0]); watch($$(tab), () => (syncSlide(tabs.indexOf(tab)))); let chartSrc = $ref('instance-requests'); -let meta = $ref(null); -let instance = $ref(null); +let meta = $ref(null); +let instance = $ref(null); let suspended = $ref(false); let isBlocked = $ref(false); let faviconUrl = $ref(null); @@ -185,19 +194,34 @@ const usersPagination = { offsetMode: true, }; -async function fetch() { - instance = await os.api('federation/show-instance', { - host: props.host, - }); - suspended = instance.isSuspended; - isBlocked = instance.isBlocked; - faviconUrl = getProxiedImageUrlNullable(instance.faviconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.iconUrl, 'preview'); +async function init() { + meta = await os.api('admin/meta'); } -async function toggleBlock(ev) { +async function fetch() { + instance = (await os.api('federation/show-instance', { + host: props.host, + })) as AugmentedInstance; + suspended = instance.isSuspended; + isBlocked = instance.isBlocked; + faviconUrl = + getProxiedImageUrlNullable(instance.faviconUrl, 'preview') ?? + getProxiedImageUrlNullable(instance.iconUrl, 'preview'); +} + +async function toggleBlock() { if (meta == null) return; + if (!instance) { + throw new Error(`Instance info not loaded`); + } + let blockedHosts: string[]; + if (isBlocked) { + blockedHosts = meta.blockedHosts.concat([instance.host]); + } else { + blockedHosts = meta.blockedHosts.filter((x) => x !== instance!.host); + } await os.api('admin/update-meta', { - blockedHosts: isBlocked ? meta.blockedHosts.concat([instance.host]) : meta.blockedHosts.filter(x => x !== instance.host), + blockedHosts, }); } From dbde28f01e0d01794b81633deb26be8a31d76935 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 3 Apr 2023 20:46:54 -0700 Subject: [PATCH 09/72] dev 26 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8878ba67d6..938afafbcd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calckey", - "version": "13.2.0-dev25", + "version": "13.2.0-dev26", "codename": "aqua", "repository": { "type": "git", From c2ac53c66b5cade26afd5622ad800bec7edffa92 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 4 Apr 2023 21:47:30 -0700 Subject: [PATCH 10/72] mkv13 media list --- .../client/src/components/MkMediaList.vue | 238 +++++++++--------- 1 file changed, 115 insertions(+), 123 deletions(-) diff --git a/packages/client/src/components/MkMediaList.vue b/packages/client/src/components/MkMediaList.vue index 8b6d2c2c95..9a1d1f1704 100644 --- a/packages/client/src/components/MkMediaList.vue +++ b/packages/client/src/components/MkMediaList.vue @@ -1,19 +1,19 @@ - From 89a010db1b3bfd27cd1ebdaa65424b451252f600 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 4 Apr 2023 21:47:38 -0700 Subject: [PATCH 11/72] dev27 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 938afafbcd..bffbba6269 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calckey", - "version": "13.2.0-dev26", + "version": "13.2.0-dev27", "codename": "aqua", "repository": { "type": "git", From 3b5b90879cd32cbe558e376adbff3a751247d99f Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 4 Apr 2023 21:53:17 -0700 Subject: [PATCH 12/72] dont change state --- packages/client/src/components/MkMediaList.vue | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/client/src/components/MkMediaList.vue b/packages/client/src/components/MkMediaList.vue index 9a1d1f1704..6dd0dea274 100644 --- a/packages/client/src/components/MkMediaList.vue +++ b/packages/client/src/components/MkMediaList.vue @@ -126,16 +126,6 @@ onMounted(() => { return; } }); - - lightbox.on('beforeOpen', () => { - history.pushState(null, '', '#pswp'); - }); - - lightbox.on('close', () => { - if (window.location.hash === '#pswp') { - history.back(); - } - }); }); const previewable = (file: misskey.entities.DriveFile): boolean => { From c88627fc8875a5d68bc913234307e4eacbd3ba07 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 4 Apr 2023 21:59:11 -0700 Subject: [PATCH 13/72] back button in settings --- packages/client/src/components/global/MkPageHeader.vue | 2 ++ packages/client/src/pages/settings/index.vue | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/global/MkPageHeader.vue b/packages/client/src/components/global/MkPageHeader.vue index a6f71d9674..8293f10e28 100644 --- a/packages/client/src/components/global/MkPageHeader.vue +++ b/packages/client/src/components/global/MkPageHeader.vue @@ -1,6 +1,7 @@