wip
This commit is contained in:
parent
a503bc04a1
commit
1857052b32
|
@ -137,6 +137,7 @@ import { mfmFunctionPicker } from '@/utility/mfm-function-picker.js';
|
|||
import { prefer } from '@/preferences.js';
|
||||
import { getPluginHandlers } from '@/plugin.js';
|
||||
import { DI } from '@/di.js';
|
||||
import { globalEvents } from '@/events.js';
|
||||
|
||||
const $i = ensureSignin();
|
||||
|
||||
|
@ -883,12 +884,15 @@ async function post(ev?: MouseEvent) {
|
|||
}
|
||||
|
||||
posting.value = true;
|
||||
misskeyApi('notes/create', postData, token).then(() => {
|
||||
misskeyApi('notes/create', postData, token).then((res) => {
|
||||
if (props.freezeAfterPosted) {
|
||||
posted.value = true;
|
||||
} else {
|
||||
clear();
|
||||
}
|
||||
|
||||
globalEvents.emit('notePosted', res.createdNote);
|
||||
|
||||
nextTick(() => {
|
||||
deleteDraft();
|
||||
emit('posted');
|
||||
|
|
|
@ -67,6 +67,7 @@ import MkNote from '@/components/MkNote.vue';
|
|||
import MkButton from '@/components/MkButton.vue';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { infoImageUrl } from '@/instance.js';
|
||||
import { globalEvents } from '@/events.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
src: BasicTimelineType | 'mentions' | 'directs' | 'list' | 'antenna' | 'channel' | 'role';
|
||||
|
@ -122,6 +123,15 @@ if (!store.s.realtimeMode) {
|
|||
});
|
||||
}
|
||||
|
||||
globalEvents.on('notePosted', (note: Misskey.entities.Note) => {
|
||||
const isTop = rootEl.value == null ? false : isHeadVisible(rootEl.value, 16);
|
||||
if (isTop) {
|
||||
paginator.fetchNewer({
|
||||
toQueue: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function releaseQueue() {
|
||||
paginator.releaseQueue();
|
||||
scrollToTop(rootEl.value);
|
||||
|
|
|
@ -10,4 +10,5 @@ export const globalEvents = new EventEmitter<{
|
|||
themeChanging: () => void;
|
||||
themeChanged: () => void;
|
||||
clientNotification: (notification: Misskey.entities.Notification) => void;
|
||||
notePosted: (note: Misskey.entities.Note) => void;
|
||||
}>();
|
||||
|
|
|
@ -65,6 +65,16 @@ export function usePagination<Ctx extends PagingCtx, T = Misskey.Endpoints[Ctx['
|
|||
// パラメータに何らかの変更があった際、再読込したい(チャンネル等のIDが変わったなど)
|
||||
watch(() => [props.ctx.endpoint, props.ctx.params], init, { deep: true });
|
||||
|
||||
function getNewestId() {
|
||||
// 様々な要因により並び順は保証されないのでソートが必要
|
||||
return Array.from(items.value.keys()).sort().at(-1);
|
||||
}
|
||||
|
||||
function getOldestId() {
|
||||
// 様々な要因により並び順は保証されないのでソートが必要
|
||||
return Array.from(items.value.keys()).sort().at(0);
|
||||
}
|
||||
|
||||
async function init(): Promise<void> {
|
||||
items.value = new Map();
|
||||
fetching.value = true;
|
||||
|
@ -110,7 +120,7 @@ export function usePagination<Ctx extends PagingCtx, T = Misskey.Endpoints[Ctx['
|
|||
...(props.ctx.offsetMode ? {
|
||||
offset: items.value.size,
|
||||
} : {
|
||||
untilId: Array.from(items.value.keys()).at(-1),
|
||||
untilId: getOldestId(),
|
||||
}),
|
||||
}).then(res => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
|
@ -141,7 +151,7 @@ export function usePagination<Ctx extends PagingCtx, T = Misskey.Endpoints[Ctx['
|
|||
...(props.ctx.offsetMode ? {
|
||||
offset: items.value.size,
|
||||
} : {
|
||||
sinceId: Array.from(items.value.keys()).at(0),
|
||||
sinceId: getNewestId(),
|
||||
}),
|
||||
}).then(res => {
|
||||
if (options.toQueue) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import { getAppearNote } from '@/utility/get-appear-note.js';
|
|||
import { genEmbedCode } from '@/utility/get-embed-code.js';
|
||||
import { prefer } from '@/preferences.js';
|
||||
import { getPluginHandlers } from '@/plugin.js';
|
||||
import { globalEvents } from '@/events.js';
|
||||
|
||||
export async function getNoteClipMenu(props: {
|
||||
note: Misskey.entities.Note;
|
||||
|
@ -569,8 +570,9 @@ export function getRenoteMenu(props: {
|
|||
misskeyApi('notes/create', {
|
||||
renoteId: appearNote.id,
|
||||
channelId: appearNote.channelId,
|
||||
}).then(() => {
|
||||
}).then((res) => {
|
||||
os.toast(i18n.ts.renoted);
|
||||
globalEvents.emit('notePosted', res.createdNote);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -617,8 +619,9 @@ export function getRenoteMenu(props: {
|
|||
localOnly,
|
||||
visibility,
|
||||
renoteId: appearNote.id,
|
||||
}).then(() => {
|
||||
}).then((res) => {
|
||||
os.toast(i18n.ts.renoted);
|
||||
globalEvents.emit('notePosted', res.createdNote);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -658,8 +661,9 @@ export function getRenoteMenu(props: {
|
|||
misskeyApi('notes/create', {
|
||||
renoteId: appearNote.id,
|
||||
channelId: channel.id,
|
||||
}).then(() => {
|
||||
}).then((res) => {
|
||||
os.toast(i18n.tsx.renotedToX({ name: channel.name }));
|
||||
globalEvents.emit('notePosted', res.createdNote);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue