Revert "hopefully this fixed chat updates"
This reverts commit bbbfbc1061
.
This commit is contained in:
parent
407f521757
commit
c8fc470e4e
3 changed files with 311 additions and 324 deletions
|
@ -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+-]+)(?:@\.)?:$/);
|
||||
|
|
|
@ -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,25 +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';
|
||||
|
||||
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;
|
||||
|
||||
|
@ -67,7 +64,6 @@ const props = withDefaults(defineProps<{
|
|||
pagination: Paging;
|
||||
disableAutoLoad?: boolean;
|
||||
displayLimit?: number;
|
||||
externalItemArray?: Ref<Array<any>>;
|
||||
}>(), {
|
||||
displayLimit: 30,
|
||||
});
|
||||
|
@ -95,7 +91,7 @@ const init = async (): Promise<void> => {
|
|||
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++) {
|
||||
|
@ -128,10 +124,10 @@ const reload = (): void => {
|
|||
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 => {
|
||||
|
@ -163,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,
|
||||
|
@ -201,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,
|
||||
|
@ -292,7 +288,7 @@ const append = (item: Item): void => {
|
|||
|
||||
const removeItem = (finder: (item: Item) => boolean): boolean => {
|
||||
const i = items.value.findIndex(finder);
|
||||
const j = props.externalItemArray?.findIndex(finder);
|
||||
if (i === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -302,8 +298,7 @@ const removeItem = (finder: (item: Item) => boolean): boolean => {
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -346,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;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { markRaw, onMounted, onUnmounted, watch, ref } 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';
|
||||
|
@ -59,16 +59,11 @@ const router = useRouter();
|
|||
|
||||
let messages = $ref([]);
|
||||
let connection = $ref(null);
|
||||
const reloadingKey = ref(0);
|
||||
|
||||
const tabs = ['dms', 'groups'];
|
||||
let tab = $ref(tabs[0]);
|
||||
watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
|
||||
|
||||
const forceRerender = () => {
|
||||
reloadingKey.value += 1;
|
||||
};
|
||||
|
||||
const headerActions = $computed(() => [{
|
||||
asFullButton: true,
|
||||
icon: 'ph-plus-bold ph-lg',
|
||||
|
@ -117,7 +112,6 @@ function onMessage(message): void {
|
|||
messages = messages.filter(m => m.groupId !== message.groupId);
|
||||
messages.unshift(message);
|
||||
}
|
||||
forceRerender();
|
||||
}
|
||||
|
||||
function onRead(ids): void {
|
||||
|
@ -189,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