feat: patron labels

This commit is contained in:
ThatOneCalculator 2023-06-06 18:43:05 -07:00
parent 71d4f5d516
commit 6825595bdc
No known key found for this signature in database
GPG key ID: 8703CACD01000000
5 changed files with 59 additions and 11 deletions

View file

@ -1099,6 +1099,11 @@ noGraze: "Please disable the \"Graze for Mastodon\" browser extension, as it int
with Calckey." with Calckey."
silencedWarning: "This page is showing because these users are from servers your admin silencedWarning: "This page is showing because these users are from servers your admin
silenced, so they may potentially be spam." silenced, so they may potentially be spam."
isBot: "This account is a bot"
isLocked: "This account has follow approvals"
isModerator: "Moderator"
isAdmin: "Administrator"
isPatron: "Calckey Patron"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "Reduces the effort of server moderation through automatically recognizing description: "Reduces the effort of server moderation through automatically recognizing

View file

@ -1,4 +1,5 @@
import define from "../define.js"; import define from "../define.js";
import Logger from "@/services/logger.js";
export const meta = { export const meta = {
tags: ["meta"], tags: ["meta"],
@ -22,6 +23,9 @@ export default define(meta, paramDef, async () => {
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
patrons = data["patrons"]; patrons = data["patrons"];
})
.catch((error) => {
console.error("Error fetching patrons:", error);
}); });
return patrons; return patrons;

View file

@ -5,6 +5,7 @@ import type * as Misskey from "calckey-js";
// TODO: 他のタブと永続化されたstateを同期 // TODO: 他のタブと永続化されたstateを同期
const instanceData = localStorage.getItem("instance"); const instanceData = localStorage.getItem("instance");
const patronData = localStorage.getItem("patrons");
// TODO: instanceをリアクティブにするかは再考の余地あり // TODO: instanceをリアクティブにするかは再考の余地あり
@ -16,6 +17,8 @@ export const instance: Misskey.entities.DetailedInstanceMetadata = reactive(
}, },
); );
export const patrons = patronData || [];
export async function fetchInstance() { export async function fetchInstance() {
const meta = await api("meta", { const meta = await api("meta", {
detail: true, detail: true,
@ -28,6 +31,11 @@ export async function fetchInstance() {
localStorage.setItem("instance", JSON.stringify(instance)); localStorage.setItem("instance", JSON.stringify(instance));
} }
export async function fetchPatrons() {
const patrons = await api("patrons");
localStorage.setItem("patrons", JSON.stringify(patrons));
}
export const emojiCategories = computed(() => { export const emojiCategories = computed(() => {
if (instance.emojis == null) return []; if (instance.emojis == null) return [];
const categories = new Set(); const categories = new Set();

View file

@ -163,14 +163,15 @@ import { i18n } from "@/i18n";
import { defaultStore } from "@/store"; import { defaultStore } from "@/store";
import * as os from "@/os"; import * as os from "@/os";
import { definePageMetadata } from "@/scripts/page-metadata"; import { definePageMetadata } from "@/scripts/page-metadata";
import { patrons, fetchPatrons } from "@/instance";
const patrons = await os.api("patrons");
let easterEggReady = false; let easterEggReady = false;
let easterEggEmojis = $ref([]); let easterEggEmojis = $ref([]);
let easterEggEngine = $ref(null); let easterEggEngine = $ref(null);
const containerEl = $ref<HTMLElement>(); const containerEl = $ref<HTMLElement>();
await fetchPatrons()
function iconLoaded() { function iconLoaded() {
const emojis = defaultStore.state.reactions; const emojis = defaultStore.state.reactions;
const containerWidth = containerEl?.offsetWidth; const containerWidth = containerEl?.offsetWidth;

View file

@ -54,7 +54,7 @@
/></span> /></span>
<span <span
v-if="user.isAdmin" v-if="user.isAdmin"
:title="i18n.ts.isAdmin" v-tooltip.noDelay="i18n.ts.isAdmin"
style="color: var(--badge)" style="color: var(--badge)"
><i ><i
class="ph-bookmark-simple ph-fill ph-lg" class="ph-bookmark-simple ph-fill ph-lg"
@ -62,22 +62,36 @@
></span> ></span>
<span <span
v-if="!user.isAdmin && user.isModerator" v-if="!user.isAdmin && user.isModerator"
:title="i18n.ts.isModerator" v-tooltip.noDelay="i18n.ts.isModerator"
style="color: var(--badge)" style="color: var(--badge)"
><i ><i
class="ph-bookmark-simple ph-bold" class="ph-bookmark-simple ph-bold ph-lg"
></i ></i
></span> ></span>
<span <span
v-if="user.isLocked" v-if="user.isLocked"
:title="i18n.ts.isLocked" v-tooltip.noDelay="i18n.ts.isLocked"
><i class="ph-lock ph-bold ph-lg"></i ><i class="ph-lock ph-bold ph-lg"></i
></span> ></span>
<span <span
v-if="user.isBot" v-if="user.isBot"
:title="i18n.ts.isBot" v-tooltip.noDelay="i18n.ts.isBot"
><i class="ph-robot ph-bold ph-lg"></i ><i class="ph-robot ph-bold ph-lg"></i
></span> ></span>
<span
v-if="
patrons?.includes(
`@${user.username}@${
user.host || host
}`
)
"
v-tooltip.noDelay="i18n.ts.isPatron"
style="color: var(--badge)"
><i
class="ph-hand-coins ph-bold ph-lg"
></i
></span>
</div> </div>
</div> </div>
</div> </div>
@ -110,7 +124,7 @@
/></span> /></span>
<span <span
v-if="user.isAdmin" v-if="user.isAdmin"
:title="i18n.ts.isAdmin" v-tooltip.noDelay="i18n.ts.isAdmin"
style="color: var(--badge)" style="color: var(--badge)"
><i ><i
class="ph-bookmark-simple ph-fill ph-lg" class="ph-bookmark-simple ph-fill ph-lg"
@ -118,18 +132,32 @@
></span> ></span>
<span <span
v-if="!user.isAdmin && user.isModerator" v-if="!user.isAdmin && user.isModerator"
:title="i18n.ts.isModerator" v-tooltip.noDelay="i18n.ts.isModerator"
style="color: var(--badge)" style="color: var(--badge)"
><i class="ph-bookmark-simple ph-bold"></i ><i class="ph-bookmark-simple ph-bold"></i
></span> ></span>
<span <span
v-if="user.isLocked" v-if="user.isLocked"
:title="i18n.ts.isLocked" v-tooltip.noDelay="i18n.ts.isLocked"
><i class="ph-lock ph-bold ph-lg"></i ><i class="ph-lock ph-bold ph-lg"></i
></span> ></span>
<span v-if="user.isBot" :title="i18n.ts.isBot" <span
v-if="user.isBot"
v-tooltip.noDelay="i18n.ts.isBot"
><i class="ph-robot ph-bold ph-lg"></i ><i class="ph-robot ph-bold ph-lg"></i
></span> ></span>
<span
v-if="
patrons?.includes(
`@${user.username}@${
user.host || host
}`
)
"
v-tooltip.noDelay="i18n.ts.isPatron"
style="color: var(--badge)"
><i class="ph-hand-coins ph-bold ph-lg"></i
></span>
</div> </div>
</div> </div>
<div class="follow-container"> <div class="follow-container">
@ -324,6 +352,8 @@ import * as os from "@/os";
import { useRouter } from "@/router"; import { useRouter } from "@/router";
import { i18n } from "@/i18n"; import { i18n } from "@/i18n";
import { $i } from "@/account"; import { $i } from "@/account";
import { host } from "@/config";
import { patrons } from "@/instance";
const XPhotos = defineAsyncComponent(() => import("./index.photos.vue")); const XPhotos = defineAsyncComponent(() => import("./index.photos.vue"));
const XActivity = defineAsyncComponent(() => import("./index.activity.vue")); const XActivity = defineAsyncComponent(() => import("./index.activity.vue"));