Skip to content

Commit

Permalink
feat: update updated-date on state changes
Browse files Browse the repository at this point in the history
when the user changes the read-state-dropdown, or the chapters read, we
now update the last-update-date as well
  • Loading branch information
mangadoot committed Jan 22, 2023
1 parent b41061a commit adc891f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import 'primevue/resources/themes/nova/theme.css';
import 'primeflex/primeflex.css';
import 'primeicons/primeicons.css';

import dayjs from 'dayjs';
import pWaitFor from 'p-wait-for';
import { createPinia, Pinia, PiniaVuePlugin } from 'pinia';
import * as PrimeVue from 'primevue/config';
import { Logger } from 'ts-log';
import { isSomething, isString } from 'ts-type-guards';
import { is, isSomething, isString } from 'ts-type-guards';
import Vue from 'vue';

import generateHeaders from '@/Header';
import NotesApp from '@/NotesApp.vue';
import { provideSiteInfo } from '@/SiteInfo';
import { useNotesStore } from '@/Stores/NotesStore';
import { type SiteInfo } from '@/types/SiteInfo';
import logger from '@/Utils/Logger';
import Settings from '@/Utils/Settings/Settings';
Expand All @@ -35,6 +37,7 @@ export default class Site {
})
.then(this.createVue.bind(this))
.then(this.createSettings.bind(this))
.then(this.addStatusListener.bind(this))
.catch((error) => this.logger.error(error));
}

Expand Down Expand Up @@ -67,6 +70,18 @@ export default class Site {
.registerDialog(pinia);
}

/** listens to the read/watch-status of the manga/anime */
private addStatusListener(): void {
const form = document.querySelector('.myListBar');
if (!is(HTMLFormElement)(form)) {
return;
}
form.addEventListener('change', () => {
const store = useNotesStore();
store.entry.updated = dayjs().unix();
});
}

private createVueTarget(): HTMLDivElement {
const sibling = document.querySelector('#entry > div:nth-child(2)');
if (sibling === null) {
Expand Down

0 comments on commit adc891f

Please sign in to comment.