Merge branch 'develop' of https://codeberg.org/calckey/calckey into note-improvements
This commit is contained in:
commit
ca971f1116
5 changed files with 366 additions and 408 deletions
10
README.md
10
README.md
|
@ -64,6 +64,9 @@ If you have access to a server that supports one of the sources below, I recomme
|
|||
|
||||
[![Install on Ubuntu](https://pool.jortage.com/voringme/misskey/3b62a443-1b44-45cf-8f9e-f1c588f803ed.png)](https://codeberg.org/calckey/ubuntu-bash-install) [![Install on the Arch User Repository](https://pool.jortage.com/voringme/misskey/ba2a5c07-f078-43f1-8483-2e01acca9c40.png)](https://aur.archlinux.org/packages/calckey) [![Install Calckey with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=calckey)
|
||||
|
||||
### 🐋 Docker
|
||||
|
||||
[How to run Calckey with Docker](./docker-README.md).
|
||||
|
||||
## 🧑💻 Dependencies
|
||||
|
||||
|
@ -103,7 +106,8 @@ cd calckey/
|
|||
# nvm install 19 && nvm use 19
|
||||
corepack enable
|
||||
corepack prepare pnpm@latest --activate
|
||||
pnpm i
|
||||
# To build without TensorFlow, append --no-optional
|
||||
pnpm i # --no-optional
|
||||
```
|
||||
|
||||
## 🐘 Create database
|
||||
|
@ -157,10 +161,6 @@ NODE_ENV=production pnpm install && pnpm run build && pnpm run migrate
|
|||
pm2 start "NODE_ENV=production pnpm run start" --name Calckey
|
||||
```
|
||||
|
||||
### 🐋 Docker
|
||||
|
||||
[How to run Calckey with Docker](./docker-README.md).
|
||||
|
||||
## 😉 Tips & Tricks
|
||||
|
||||
- When editing the config file, please don't fill out the settings at the bottom. They're designed *only* for managed hosting, not self hosting. Those settings are much better off being set in Calckey's control panel.
|
||||
|
|
|
@ -68,7 +68,7 @@ export async function toDbReaction(
|
|||
const match = emojiRegex.exec(reaction);
|
||||
if (match) {
|
||||
const unicode = match[0];
|
||||
return unicode.match('\u200d') ? unicode : unicode.replace(/\ufe0f/g, '');
|
||||
return unicode.match("\u200d") ? unicode : unicode.replace(/\ufe0f/g, "");
|
||||
}
|
||||
|
||||
const custom = reaction.match(/^:([\w+-]+)(?:@\.)?:$/);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<MkPagination ref="pagingComponent" :pagination="pagination" disableReload="true">
|
||||
<MkPagination ref="pagingComponent" :pagination="pagination">
|
||||
<template #empty>
|
||||
<div class="_fullinfo">
|
||||
<img src="/static-assets/badges/info.png" class="_ghost" alt="Info"/>
|
||||
|
|
|
@ -15,17 +15,14 @@
|
|||
|
||||
<div v-else ref="rootEl">
|
||||
<div v-show="pagination.reversed && more" key="_more_" class="cxiknjgy _gap">
|
||||
<MkButton v-if="!moreFetching" class="button" :disabled="moreFetching"
|
||||
:style="{ cursor: moreFetching ? 'wait' : 'pointer' }" primary @click="fetchMoreAhead">
|
||||
<MkButton v-if="!moreFetching" class="button" :disabled="moreFetching" :style="{ cursor: moreFetching ? 'wait' : 'pointer' }" primary @click="fetchMoreAhead">
|
||||
{{ i18n.ts.loadMore }}
|
||||
</MkButton>
|
||||
<MkLoading v-else class="loading"/>
|
||||
</div>
|
||||
<slot :items="items"></slot>
|
||||
<div v-show="!pagination.reversed && more" key="_more_" class="cxiknjgy _gap">
|
||||
<MkButton v-if="!moreFetching"
|
||||
v-appear="($store.state.enableInfiniteScroll && !disableAutoLoad) ? fetchMore : null" class="button"
|
||||
:disabled="moreFetching" :style="{ cursor: moreFetching ? 'wait' : 'pointer' }" primary @click="fetchMore">
|
||||
<MkButton v-if="!moreFetching" v-appear="($store.state.enableInfiniteScroll && !disableAutoLoad) ? fetchMore : null" class="button" :disabled="moreFetching" :style="{ cursor: moreFetching ? 'wait' : 'pointer' }" primary @click="fetchMore">
|
||||
{{ i18n.ts.loadMore }}
|
||||
</MkButton>
|
||||
<MkLoading v-else class="loading"/>
|
||||
|
@ -36,26 +33,25 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ComputedRef, isRef, markRaw, onActivated, onDeactivated, Ref, ref, watch } from 'vue';
|
||||
import * as calckey from 'calckey-js';
|
||||
import * as misskey from 'calckey-js';
|
||||
import * as os from '@/os';
|
||||
import { onScrollTop, isTopVisible, getScrollPosition, getScrollContainer } from '@/scripts/scroll';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import { i18n } from '@/i18n';
|
||||
import { ItemHolder } from 'photoswipe';
|
||||
|
||||
export type Paging<E extends keyof calckey.Endpoints = keyof calckey.Endpoints> = {
|
||||
export type Paging<E extends keyof misskey.Endpoints = keyof misskey.Endpoints> = {
|
||||
endpoint: E;
|
||||
limit: number;
|
||||
params?: calckey.Endpoints[E]['req'] | ComputedRef<calckey.Endpoints[E]['req']>;
|
||||
params?: misskey.Endpoints[E]['req'] | ComputedRef<misskey.Endpoints[E]['req']>;
|
||||
|
||||
/**
|
||||
* When using non-pageable endpoints, such as the search API
|
||||
* (though it is somewhat inconsistent to use such an API with this function)
|
||||
* 検索APIのような、ページング不可なエンドポイントを利用する場合
|
||||
* (そのようなAPIをこの関数で使うのは若干矛盾してるけど)
|
||||
*/
|
||||
noPaging?: boolean;
|
||||
|
||||
/**
|
||||
* array items in reverse order (newest first)
|
||||
* items 配列の中身を逆順にする(新しい方が最後)
|
||||
*/
|
||||
reversed?: boolean;
|
||||
|
||||
|
@ -68,8 +64,6 @@ const props = withDefaults(defineProps<{
|
|||
pagination: Paging;
|
||||
disableAutoLoad?: boolean;
|
||||
displayLimit?: number;
|
||||
externalItemArray?: Ref<Array<any>>;
|
||||
disableReload?: boolean;
|
||||
}>(), {
|
||||
displayLimit: 30,
|
||||
});
|
||||
|
@ -91,14 +85,13 @@ const backed = ref(false); // 遡り中か否か
|
|||
const isBackTop = ref(false);
|
||||
const empty = computed(() => items.value.length === 0);
|
||||
const error = ref(false);
|
||||
const alreadyInitedOnce = ref(false);
|
||||
|
||||
const init = async (): Promise<void> => {
|
||||
queue.value = [];
|
||||
fetching.value = true;
|
||||
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
|
||||
await os.api(props.pagination.endpoint, {
|
||||
...(params as object),
|
||||
...params,
|
||||
limit: props.pagination.noPaging ? (props.pagination.limit || 10) : (props.pagination.limit || 10) + 1,
|
||||
}).then(res => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
|
@ -112,15 +105,9 @@ const init = async (): Promise<void> => {
|
|||
if (!props.pagination.noPaging && (res.length > (props.pagination.limit || 10))) {
|
||||
res.pop();
|
||||
items.value = props.pagination.reversed ? [...res].reverse() : res;
|
||||
if (props.externalItemArray) {
|
||||
props.externalItemArray.value = items.value;
|
||||
}
|
||||
more.value = true;
|
||||
} else {
|
||||
items.value = props.pagination.reversed ? [...res].reverse() : res;
|
||||
if (props.externalItemArray) {
|
||||
props.externalItemArray.value = items.value;
|
||||
}
|
||||
more.value = false;
|
||||
}
|
||||
offset.value = res.length;
|
||||
|
@ -134,16 +121,13 @@ const init = async (): Promise<void> => {
|
|||
|
||||
const reload = (): void => {
|
||||
items.value = [];
|
||||
if (props.externalItemArray) {
|
||||
props.externalItemArray.value = [];
|
||||
}
|
||||
init();
|
||||
};
|
||||
|
||||
const refresh = async (): Promise<void> => {
|
||||
const refresh = async (): void => {
|
||||
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
|
||||
await os.api(props.pagination.endpoint, {
|
||||
...(params as object),
|
||||
...params,
|
||||
limit: items.value.length + 1,
|
||||
offset: 0,
|
||||
}).then(res => {
|
||||
|
@ -175,7 +159,7 @@ const fetchMore = async (): Promise<void> => {
|
|||
backed.value = true;
|
||||
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
|
||||
await os.api(props.pagination.endpoint, {
|
||||
...(params as object),
|
||||
...params,
|
||||
limit: SECOND_FETCH_LIMIT + 1,
|
||||
...(props.pagination.offsetMode ? {
|
||||
offset: offset.value,
|
||||
|
@ -196,15 +180,9 @@ const fetchMore = async (): Promise<void> => {
|
|||
if (res.length > SECOND_FETCH_LIMIT) {
|
||||
res.pop();
|
||||
items.value = props.pagination.reversed ? [...res].reverse().concat(items.value) : items.value.concat(res);
|
||||
if (props.externalItemArray) {
|
||||
props.externalItemArray.value = items.value;
|
||||
}
|
||||
more.value = true;
|
||||
} else {
|
||||
items.value = props.pagination.reversed ? [...res].reverse().concat(items.value) : items.value.concat(res);
|
||||
if (props.externalItemArray) {
|
||||
props.externalItemArray.value = items.value;
|
||||
}
|
||||
more.value = false;
|
||||
}
|
||||
offset.value += res.length;
|
||||
|
@ -219,7 +197,7 @@ const fetchMoreAhead = async (): Promise<void> => {
|
|||
moreFetching.value = true;
|
||||
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
|
||||
await os.api(props.pagination.endpoint, {
|
||||
...(params as object),
|
||||
...params,
|
||||
limit: SECOND_FETCH_LIMIT + 1,
|
||||
...(props.pagination.offsetMode ? {
|
||||
offset: offset.value,
|
||||
|
@ -232,15 +210,9 @@ const fetchMoreAhead = async (): Promise<void> => {
|
|||
if (res.length > SECOND_FETCH_LIMIT) {
|
||||
res.pop();
|
||||
items.value = props.pagination.reversed ? [...res].reverse().concat(items.value) : items.value.concat(res);
|
||||
if (props.externalItemArray) {
|
||||
props.externalItemArray.value = items.value;
|
||||
}
|
||||
more.value = true;
|
||||
} else {
|
||||
items.value = props.pagination.reversed ? [...res].reverse().concat(items.value) : items.value.concat(res);
|
||||
if (props.externalItemArray) {
|
||||
props.externalItemArray.value = items.value;
|
||||
}
|
||||
more.value = false;
|
||||
}
|
||||
offset.value += res.length;
|
||||
|
@ -268,7 +240,6 @@ const prepend = (item: Item): void => {
|
|||
//items.value = items.value.slice(-props.displayLimit);
|
||||
while (items.value.length >= props.displayLimit) {
|
||||
items.value.shift();
|
||||
if (props.externalItemArray) props.externalItemArray.value.shift();
|
||||
}
|
||||
more.value = true;
|
||||
}
|
||||
|
@ -276,13 +247,11 @@ const prepend = (item: Item): void => {
|
|||
}
|
||||
}
|
||||
items.value.push(item);
|
||||
if (props.externalItemArray) props.externalItemArray.value.push(item);
|
||||
// TODO
|
||||
} else {
|
||||
// 初回表示時はunshiftだけでOK
|
||||
if (!rootEl.value) {
|
||||
items.value.unshift(item);
|
||||
if (props.externalItemArray) props.externalItemArray.value.unshift(item);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -291,7 +260,16 @@ const prepend = (item: Item): void => {
|
|||
if (isTop) {
|
||||
// Prepend the item
|
||||
items.value.unshift(item);
|
||||
if (props.externalItemArray) props.externalItemArray.value.unshift(item);
|
||||
|
||||
// オーバーフローしたら古いアイテムは捨てる
|
||||
if (items.value.length >= props.displayLimit) {
|
||||
// このやり方だとVue 3.2以降アニメーションが動かなくなる
|
||||
//this.items = items.value.slice(0, props.displayLimit);
|
||||
while (items.value.length >= props.displayLimit) {
|
||||
items.value.pop();
|
||||
}
|
||||
more.value = true;
|
||||
}
|
||||
} else {
|
||||
queue.value.push(item);
|
||||
onScrollTop(rootEl.value, () => {
|
||||
|
@ -306,30 +284,25 @@ const prepend = (item: Item): void => {
|
|||
|
||||
const append = (item: Item): void => {
|
||||
items.value.push(item);
|
||||
if (props.externalItemArray) props.externalItemArray.value.push(item);
|
||||
};
|
||||
|
||||
const removeItem = (finder: (item: Item) => boolean): boolean => {
|
||||
const i = items.value.findIndex(finder);
|
||||
const j = props.externalItemArray?.findIndex(finder);
|
||||
if (i === -1 && j === -1) {
|
||||
if (i === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
items.value.splice(i, 1);
|
||||
if (props.externalItemArray) props.externalItemArray.value.splice(i, 1);
|
||||
return true;
|
||||
};
|
||||
|
||||
const updateItem = (id: Item['id'], replacer: (old: Item) => Item): boolean => {
|
||||
const i = items.value.findIndex(item => item.id === id);
|
||||
const j = props.externalItemArray?.findIndex(item => item.id === id);
|
||||
if (i === -1 && j === -1) {
|
||||
if (i === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
items.value[i] = replacer(items.value[i]);
|
||||
if (props.externalItemArray) props.externalItemArray.value[i] = items.value[i];
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -346,14 +319,10 @@ init();
|
|||
|
||||
onActivated(() => {
|
||||
isBackTop.value = false;
|
||||
if(alreadyInitedOnce.value && (!props.disableReload || !props.disableReload.value)) {
|
||||
reload();
|
||||
}
|
||||
});
|
||||
|
||||
onDeactivated(() => {
|
||||
isBackTop.value = window.scrollY === 0;
|
||||
alreadyInitedOnce.value = true;
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
|
@ -372,9 +341,8 @@ defineExpose({
|
|||
<style lang="scss" scoped>
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.15s ease;
|
||||
transition: opacity 0.125s ease;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
|
|
|
@ -1,36 +1,32 @@
|
|||
<template>
|
||||
<MkStickyContainer>
|
||||
<template #header>
|
||||
<MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs" />
|
||||
</template>
|
||||
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
||||
<div>
|
||||
<MkSpacer :content-max="800">
|
||||
<swiper :modules="[Virtual]" :space-between="20" :virtual="true"
|
||||
:allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef"
|
||||
@slide-change="onSlideChange">
|
||||
<swiper
|
||||
:modules="[Virtual]"
|
||||
:space-between="20"
|
||||
:virtual="true"
|
||||
:allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)"
|
||||
@swiper="setSwiperRef"
|
||||
@slide-change="onSlideChange"
|
||||
>
|
||||
<swiper-slide>
|
||||
<div class="_content yweeujhr dms">
|
||||
<MkButton primary class="start" @click="startUser"><i class="ph-plus-bold ph-lg"></i> {{
|
||||
i18n.ts.startMessaging
|
||||
}}</MkButton>
|
||||
<MkButton primary class="start" @click="startUser"><i class="ph-plus-bold ph-lg"></i> {{ i18n.ts.startMessaging }}</MkButton>
|
||||
<MkPagination v-slot="{items}" :pagination="dmsPagination">
|
||||
<MkChatPreview v-for="message in items" :key="message.id" class="yweeujhr message _block"
|
||||
:message="message" />
|
||||
<MkChatPreview v-for="message in items" :key="message.id" class="yweeujhr message _block" :message="message"/>
|
||||
</MkPagination>
|
||||
</div>
|
||||
</swiper-slide>
|
||||
<swiper-slide>
|
||||
<div class="_content yweeujhr groups">
|
||||
<div class="groupsbuttons">
|
||||
<MkButton primary class="start" :link="true" to="/my/groups"><i
|
||||
class="ph-user-circle-gear-bold ph-lg"></i> {{ i18n.ts.manageGroups }}</MkButton>
|
||||
<MkButton primary class="start" @click="startGroup"><i class="ph-plus-bold ph-lg"></i> {{
|
||||
i18n.ts.startMessaging
|
||||
}}</MkButton>
|
||||
<MkButton primary class="start" :link="true" to="/my/groups"><i class="ph-user-circle-gear-bold ph-lg"></i> {{ i18n.ts.manageGroups }}</MkButton>
|
||||
<MkButton primary class="start" @click="startGroup"><i class="ph-plus-bold ph-lg"></i> {{ i18n.ts.startMessaging }}</MkButton>
|
||||
</div>
|
||||
<MkPagination v-slot="{items}" :pagination="groupsPagination">
|
||||
<MkChatPreview v-for="message in items" :key="message.id" class="yweeujhr message _block"
|
||||
:message="message" />
|
||||
<MkChatPreview v-for="message in items" :key="message.id" class="yweeujhr message _block" :message="message"/>
|
||||
</MkPagination>
|
||||
</div>
|
||||
</swiper-slide>
|
||||
|
@ -41,7 +37,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { markRaw, onMounted, onUnmounted, watch, computed } from 'vue';
|
||||
import { markRaw, onMounted, onUnmounted, watch } from 'vue';
|
||||
import * as Acct from 'calckey-js/built/acct';
|
||||
import { Virtual } from 'swiper';
|
||||
import { Swiper, SwiperSlide } from 'swiper/vue';
|
||||
|
@ -63,8 +59,6 @@ const router = useRouter();
|
|||
|
||||
let messages = $ref([]);
|
||||
let connection = $ref(null);
|
||||
let paginationComponentUser = $ref<InstanceType<typeof MkPagination>>();
|
||||
let paginationComponentGroup = $ref<InstanceType<typeof MkPagination>>();
|
||||
|
||||
const tabs = ['dms', 'groups'];
|
||||
let tab = $ref(tabs[0]);
|
||||
|
@ -94,19 +88,17 @@ definePageMetadata({
|
|||
|
||||
const dmsPagination = {
|
||||
endpoint: 'messaging/history' as const,
|
||||
limit: 20,
|
||||
params: computed(() => ({
|
||||
limit: 15,
|
||||
params: {
|
||||
group: false,
|
||||
})),
|
||||
offsetMode: true,
|
||||
},
|
||||
};
|
||||
const groupsPagination = {
|
||||
endpoint: 'messaging/history' as const,
|
||||
limit: 10,
|
||||
params: computed(() => ({
|
||||
limit: 5,
|
||||
params: {
|
||||
group: true,
|
||||
})),
|
||||
offsetMode: true,
|
||||
},
|
||||
};
|
||||
|
||||
function onMessage(message): void {
|
||||
|
@ -120,7 +112,6 @@ function onMessage(message): void {
|
|||
messages = messages.filter(m => m.groupId !== message.groupId);
|
||||
messages.unshift(message);
|
||||
}
|
||||
forceRerender();
|
||||
}
|
||||
|
||||
function onRead(ids): void {
|
||||
|
@ -192,12 +183,11 @@ function syncSlide(index) {
|
|||
}
|
||||
|
||||
onMounted(() => {
|
||||
syncSlide(tabs.indexOf(swiperRef?.activeIndex));
|
||||
syncSlide(tabs.indexOf(swiperRef.activeIndex));
|
||||
|
||||
connection = markRaw(stream.useChannel('messagingIndex'));
|
||||
|
||||
connection.on('message', onMessage);
|
||||
connection.on('messagingMessage', onMessage);
|
||||
connection.on('read', onRead);
|
||||
|
||||
os.api('messaging/history', { group: false, limit: 5 }).then(userMessages => {
|
||||
|
|
Loading…
Reference in a new issue