Merge branch 'develop' of https://codeberg.org/calckey/calckey into note-improvements
This commit is contained in:
commit
eac3699bd2
|
@ -31,7 +31,7 @@ FROM node:19-alpine
|
||||||
WORKDIR /calckey
|
WORKDIR /calckey
|
||||||
|
|
||||||
# Install runtime dependencies
|
# Install runtime dependencies
|
||||||
RUN apk add --no-cache --no-progress tini ffmpeg
|
RUN apk add --no-cache --no-progress tini ffmpeg vips-dev
|
||||||
|
|
||||||
COPY . ./
|
COPY . ./
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ const colors = [
|
||||||
["#eb6f92", "#b4637a"],
|
["#eb6f92", "#b4637a"],
|
||||||
["#f6c177", "#ea9d34"],
|
["#f6c177", "#ea9d34"],
|
||||||
["#ebbcba", "#d7827e"],
|
["#ebbcba", "#d7827e"],
|
||||||
["#31748f", "#286983"],
|
|
||||||
["#9ccfd8", "#56949f"],
|
["#9ccfd8", "#56949f"],
|
||||||
["#c4a7e7", "#907aa9"],
|
["#c4a7e7", "#907aa9"],
|
||||||
["#eb6f92", "#f6c177"],
|
["#eb6f92", "#f6c177"],
|
||||||
|
|
|
@ -4,73 +4,71 @@ import { Emojis } from "@/models/index.js";
|
||||||
import { toPunyNullable } from "./convert-host.js";
|
import { toPunyNullable } from "./convert-host.js";
|
||||||
import { IsNull } from "typeorm";
|
import { IsNull } from "typeorm";
|
||||||
|
|
||||||
const legacies: Record<string, string> = {
|
const legacies = new Map([
|
||||||
like: "👍",
|
["like", "👍"],
|
||||||
love: "❤️", // ここに記述する場合は異体字セレクタを入れない <- not that good because modern browsers just display it as the red heart so just convert it to it to not end up with two seperate reactions of "the same emoji" for the user
|
["love", "❤️"],
|
||||||
laugh: "😆",
|
["laugh", "😆"],
|
||||||
hmm: "🤔",
|
["hmm", "🤔"],
|
||||||
surprise: "😮",
|
["surprise", "😮"],
|
||||||
congrats: "🎉",
|
["congrats", "🎉"],
|
||||||
angry: "💢",
|
["angry", "💢"],
|
||||||
confused: "😥",
|
["confused", "😥"],
|
||||||
rip: "😇",
|
["rip", "😇"],
|
||||||
pudding: "🍮",
|
["pudding", "🍮"],
|
||||||
star: "⭐",
|
["star", "⭐"],
|
||||||
};
|
]);
|
||||||
|
|
||||||
export async function getFallbackReaction(): Promise<string> {
|
export async function getFallbackReaction() {
|
||||||
const meta = await fetchMeta();
|
const meta = await fetchMeta();
|
||||||
return meta.defaultReaction;
|
return meta.defaultReaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertLegacyReactions(reactions: Record<string, number>) {
|
export function convertLegacyReactions(reactions: Record<string, number>) {
|
||||||
const _reactions = {} as Record<string, number>;
|
const _reactions = new Map();
|
||||||
|
const decodedReactions = new Map();
|
||||||
|
|
||||||
for (const reaction of Object.keys(reactions)) {
|
for (const reaction in reactions) {
|
||||||
if (reactions[reaction] <= 0) continue;
|
if (reactions[reaction] <= 0) continue;
|
||||||
|
|
||||||
if (Object.keys(legacies).includes(reaction)) {
|
let decodedReaction;
|
||||||
if (_reactions[legacies[reaction]]) {
|
if (decodedReactions.has(reaction)) {
|
||||||
_reactions[legacies[reaction]] += reactions[reaction];
|
decodedReaction = decodedReactions.get(reaction);
|
||||||
} else {
|
|
||||||
_reactions[legacies[reaction]] = reactions[reaction];
|
|
||||||
}
|
|
||||||
} else if (reaction === "♥️") {
|
|
||||||
if (_reactions["❤️"]) {
|
|
||||||
_reactions["❤️"] += reactions[reaction];
|
|
||||||
} else {
|
|
||||||
_reactions["❤️"] = reactions[reaction];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (_reactions[reaction]) {
|
decodedReaction = decodeReaction(reaction);
|
||||||
_reactions[reaction] += reactions[reaction];
|
decodedReactions.set(reaction, decodedReaction);
|
||||||
} else {
|
}
|
||||||
_reactions[reaction] = reactions[reaction];
|
|
||||||
}
|
let emoji = legacies.get(decodedReaction.reaction);
|
||||||
|
if (emoji) {
|
||||||
|
_reactions.set(emoji, (_reactions.get(emoji) || 0) + reactions[reaction]);
|
||||||
|
} else {
|
||||||
|
_reactions.set(
|
||||||
|
reaction,
|
||||||
|
(_reactions.get(reaction) || 0) + reactions[reaction],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const _reactions2 = {} as Record<string, number>;
|
const _reactions2 = new Map();
|
||||||
|
for (const [reaction, count] of _reactions) {
|
||||||
for (const reaction of Object.keys(_reactions)) {
|
const decodedReaction = decodedReactions.get(reaction);
|
||||||
_reactions2[decodeReaction(reaction).reaction] = _reactions[reaction];
|
_reactions2.set(decodedReaction.reaction, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _reactions2;
|
return Object.fromEntries(_reactions2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function toDbReaction(
|
export async function toDbReaction(
|
||||||
reaction?: string | null,
|
reaction?: string | null,
|
||||||
reacterHost?: string | null,
|
reacterHost?: string | null,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (reaction == null) return await getFallbackReaction();
|
if (!reaction) return await getFallbackReaction();
|
||||||
|
|
||||||
reacterHost = toPunyNullable(reacterHost);
|
reacterHost = toPunyNullable(reacterHost);
|
||||||
|
|
||||||
// Convert string-type reactions to unicode
|
// Convert string-type reactions to unicode
|
||||||
if (Object.keys(legacies).includes(reaction)) return legacies[reaction];
|
const emoji = legacies.get(reaction) || (reaction === "♥️" ? "❤️" : null);
|
||||||
// Convert old heart to new
|
if (emoji) return emoji;
|
||||||
if (reaction === "♥️") return "❤️";
|
|
||||||
|
|
||||||
// Allow unicode reactions
|
// Allow unicode reactions
|
||||||
const match = emojiRegex.exec(reaction);
|
const match = emojiRegex.exec(reaction);
|
||||||
|
@ -83,7 +81,7 @@ export async function toDbReaction(
|
||||||
if (custom) {
|
if (custom) {
|
||||||
const name = custom[1];
|
const name = custom[1];
|
||||||
const emoji = await Emojis.findOneBy({
|
const emoji = await Emojis.findOneBy({
|
||||||
host: reacterHost ?? IsNull(),
|
host: reacterHost || IsNull(),
|
||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -132,7 +130,7 @@ export function decodeReaction(str: string): DecodedReaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertLegacyReaction(reaction: string): string {
|
export function convertLegacyReaction(reaction: string): string {
|
||||||
reaction = decodeReaction(reaction).reaction;
|
const decoded = decodeReaction(reaction).reaction;
|
||||||
if (Object.keys(legacies).includes(reaction)) return legacies[reaction];
|
if (legacies.has(decoded)) return legacies.get(decoded)!;
|
||||||
return reaction;
|
return decoded;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,17 +32,23 @@ export const paramDef = {
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export default define(meta, paramDef, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const query = ChannelFollowings.createQueryBuilder('following').andWhere({ followerId: me.id });
|
const query = ChannelFollowings.createQueryBuilder("following").andWhere({
|
||||||
|
followerId: me.id,
|
||||||
|
});
|
||||||
if (ps.sinceId) {
|
if (ps.sinceId) {
|
||||||
query.andWhere('following."followeeId" > :sinceId', { sinceId: ps.sinceId });
|
query.andWhere('following."followeeId" > :sinceId', {
|
||||||
|
sinceId: ps.sinceId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (ps.untilId) {
|
if (ps.untilId) {
|
||||||
query.andWhere('following."followeeId" < :untilId', { untilId: ps.untilId });
|
query.andWhere('following."followeeId" < :untilId', {
|
||||||
|
untilId: ps.untilId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (ps.sinceId && !ps.untilId) {
|
if (ps.sinceId && !ps.untilId) {
|
||||||
query.orderBy('following."followeeId"', 'ASC');
|
query.orderBy('following."followeeId"', "ASC");
|
||||||
} else {
|
} else {
|
||||||
query.orderBy('following."followeeId"', 'DESC');
|
query.orderBy('following."followeeId"', "DESC");
|
||||||
}
|
}
|
||||||
|
|
||||||
const followings = await query.take(ps.limit).getMany();
|
const followings = await query.take(ps.limit).getMany();
|
||||||
|
|
|
@ -1,35 +1,36 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="show" ref="el" class="fdidabkb" :class="{ slim: narrow, thin: thin_ }" :style="{ background: bg }" @click="onClick">
|
<div ref="el" class="fdidabkb" :class="classes" :style="{ background: bg }" @click="onClick">
|
||||||
<div v-if="narrow" class="buttons left" @click="openAccountMenu">
|
<div v-show="narrow" class="buttons left" @click="openAccountMenu">
|
||||||
<MkAvatar v-if="props.displayMyAvatar && $i" class="avatar" :user="$i" :disable-preview="true"/>
|
<MkAvatar v-if="displayMyAvatar && user" class="avatar" :user="user" :disable-preview="true"/>
|
||||||
</div>
|
</div>
|
||||||
<template v-if="metadata">
|
<template v-if="hasTabs">
|
||||||
<div v-if="!hideTitle" class="titleContainer" @click="showTabsPopup">
|
<div v-show="!hideTitle" class="titleContainer" @click="showTabsPopup">
|
||||||
<MkAvatar v-if="metadata.avatar" class="avatar" :user="metadata.avatar" :disable-preview="true" :show-indicator="true"/>
|
<MkAvatar v-if="metadata.avatar" class="avatar" :user="metadata.avatar" :disable-preview="true" :show-indicator="true"/>
|
||||||
<i v-else-if="metadata.icon && !narrow" class="icon" :class="metadata.icon"></i>
|
<i v-else-if="metadata.icon && !narrow" class="icon" :class="metadata.icon"></i>
|
||||||
|
<div class="title">
|
||||||
<div class="title">
|
<MkUserName v-if="metadata.userName" :user="metadata.userName" :nowrap="true" class="title"/>
|
||||||
<MkUserName v-if="metadata.userName" :user="metadata.userName" :nowrap="true" class="title"/>
|
<div v-else-if="metadata.title && !hasTabs && !narrow" class="title">{{ metadata.title }}</div>
|
||||||
<div v-else-if="metadata.title && !(tabs != null && tabs.length > 0 && narrow)" class="title">{{ metadata.title }}</div>
|
<div v-show="!narrow && metadata.subtitle" class="subtitle">{{ metadata.subtitle }}</div>
|
||||||
<div v-if="!narrow && metadata.subtitle" class="subtitle">
|
</div>
|
||||||
{{ metadata.subtitle }}
|
</div>
|
||||||
</div>
|
<div ref="tabsEl" class="tabs" v-show="hasTabs">
|
||||||
</div>
|
<button v-for="tab in tabs" :key="tab.key" ref="tabRefs[tab.key]" v-tooltip.noDelay="tab.title"
|
||||||
</div>
|
class="tab _button" :class="{ active: isActiveTab(tab) }" @mousedown="onTabMousedown(tab)"
|
||||||
<div ref="tabsEl" v-if="hasTabs" class="tabs">
|
@click="onTabClick(tab)">
|
||||||
<button v-for="tab in tabs" :ref="(el) => tabRefs[tab.key] = el" v-tooltip.noDelay="tab.title" class="tab _button" :class="{ active: tab.key != null && tab.key === props.tab }" @mousedown="(ev) => onTabMousedown(tab, ev)" @click="(ev) => onTabClick(tab, ev)">
|
<i v-if="tab.icon && !tab.iconOnly" class="icon" :class="tab.icon"></i>
|
||||||
<i v-if="tab.icon" class="icon" :class="tab.icon"></i>
|
<span class="title">{{ tab.title }}</span>
|
||||||
<span class="title">{{ tab.title }}</span>
|
</button>
|
||||||
</button>
|
<div ref="tabHighlightEl" class="highlight"></div>
|
||||||
<div ref="tabHighlightEl" class="highlight"></div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
<div v-show="hasActions" class="buttons right">
|
||||||
<div class="buttons right">
|
<button v-for="(action, index) in actions" :key="index" v-tooltip.noDelay="action.text"
|
||||||
<template v-for="action in actions">
|
class="_button button" :class="{ highlighted: action.highlighted }" @click.stop="action.handler"
|
||||||
<button v-tooltip.noDelay="action.text" class="_button button" :class="{ highlighted: action.highlighted }" @click.stop="action.handler" @touchstart="preventDrag"><i :class="action.icon"></i></button>
|
@touchstart="preventDrag">
|
||||||
</template>
|
<i :class="action.icon"></i>
|
||||||
</div>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
Loading…
Reference in New Issue