dev: use reactiveState in foldNotification
This commit is contained in:
parent
425b333474
commit
9138c3726a
3 changed files with 8 additions and 13 deletions
|
@ -79,11 +79,13 @@ const stream = useStream();
|
||||||
|
|
||||||
const pagingComponent = ref<MkPaginationType<"i/notifications"> | null>(null);
|
const pagingComponent = ref<MkPaginationType<"i/notifications"> | null>(null);
|
||||||
|
|
||||||
const shouldFold = defaultStore.state.foldNotification;
|
const shouldFold = defaultStore.reactiveState.foldNotification;
|
||||||
|
|
||||||
|
const convertNotification = computed(() => shouldFold.value ? foldNotifications : (ns: entities.Notification[]) => ns);
|
||||||
|
|
||||||
const FETCH_LIMIT = 90;
|
const FETCH_LIMIT = 90;
|
||||||
|
|
||||||
const pagination = Object.assign(
|
const pagination = computed(() => Object.assign(
|
||||||
{
|
{
|
||||||
endpoint: "i/notifications" as const,
|
endpoint: "i/notifications" as const,
|
||||||
params: computed(() => ({
|
params: computed(() => ({
|
||||||
|
@ -94,7 +96,7 @@ const pagination = Object.assign(
|
||||||
unreadOnly: props.unreadOnly,
|
unreadOnly: props.unreadOnly,
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
shouldFold
|
shouldFold.value
|
||||||
? {
|
? {
|
||||||
limit: 50,
|
limit: 50,
|
||||||
secondFetchLimit: FETCH_LIMIT,
|
secondFetchLimit: FETCH_LIMIT,
|
||||||
|
@ -102,7 +104,7 @@ const pagination = Object.assign(
|
||||||
: {
|
: {
|
||||||
limit: 30,
|
limit: 30,
|
||||||
},
|
},
|
||||||
);
|
));
|
||||||
|
|
||||||
function isNoteNotification(
|
function isNoteNotification(
|
||||||
n: entities.Notification,
|
n: entities.Notification,
|
||||||
|
@ -138,14 +140,6 @@ const onNotification = (notification: entities.Notification) => {
|
||||||
|
|
||||||
let connection: StreamTypes.ChannelOf<"main"> | undefined;
|
let connection: StreamTypes.ChannelOf<"main"> | undefined;
|
||||||
|
|
||||||
function convertNotification(ns: entities.Notification[]) {
|
|
||||||
if (shouldFold) {
|
|
||||||
return foldNotifications(ns);
|
|
||||||
} else {
|
|
||||||
return ns;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
connection = stream.useChannel("main");
|
connection = stream.useChannel("main");
|
||||||
connection.on("notification", onNotification);
|
connection.on("notification", onNotification);
|
||||||
|
|
|
@ -486,6 +486,8 @@ if (props.pagination.params && isRef<Param>(props.pagination.params)) {
|
||||||
watch(props.pagination.params, reload, { deep: true });
|
watch(props.pagination.params, reload, { deep: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(() => props.folder, calculateItems);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
queue,
|
queue,
|
||||||
(a, b) => {
|
(a, b) => {
|
||||||
|
|
|
@ -623,7 +623,6 @@ watch(
|
||||||
enableTimelineStreaming,
|
enableTimelineStreaming,
|
||||||
enablePullToRefresh,
|
enablePullToRefresh,
|
||||||
pullToRefreshThreshold,
|
pullToRefreshThreshold,
|
||||||
foldNotification,
|
|
||||||
],
|
],
|
||||||
async () => {
|
async () => {
|
||||||
await reloadAsk();
|
await reloadAsk();
|
||||||
|
|
Loading…
Reference in a new issue