Skip to content

Commit

Permalink
Merge pull request #352 from mytlogos/pinia
Browse files Browse the repository at this point in the history
Pinia
  • Loading branch information
mytlogos authored Aug 11, 2022
2 parents 8bde789 + 07691b3 commit 0b34e1a
Show file tree
Hide file tree
Showing 42 changed files with 1,774 additions and 1,996 deletions.
129 changes: 120 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/server/src/api/episode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export const getDisplayReleases = createHandler(
until,
read,
uuid,
ignored_lists: ignoredLists,
required_lists: requiredLists,
ignored_media: ignoredMedia,
required_media: requiredMedia,
ignore_lists: ignoredLists,
only_lists: requiredLists,
ignore_media: ignoredMedia,
only_media: requiredMedia,
}: GetDisplayReleases = req.query as any;

const latestDate = getDate(latest);
Expand Down
16 changes: 8 additions & 8 deletions packages/server/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ export interface GetDisplayReleases {
latest: string;
until?: string;
read?: boolean;
ignored_lists?: Id[];
required_lists?: Id[];
ignored_media?: Id[];
required_media?: Id[];
ignore_lists?: Id[];
only_lists?: Id[];
ignore_media?: Id[];
only_media?: Id[];
}

export const getDisplayReleasesSchema: JSONSchemaType<GetDisplayReleases> = {
Expand All @@ -321,10 +321,10 @@ export const getDisplayReleasesSchema: JSONSchemaType<GetDisplayReleases> = {
latest: string(),
until: { type: "string", nullable: true },
read: { type: "boolean", nullable: true },
ignored_lists: { type: "array", items: id(), nullable: true },
ignored_media: { type: "array", items: id(), nullable: true },
required_lists: { type: "array", items: id(), nullable: true },
required_media: { type: "array", items: id(), nullable: true },
ignore_lists: { type: "array", items: id(), nullable: true },
ignore_media: { type: "array", items: id(), nullable: true },
only_lists: { type: "array", items: id(), nullable: true },
only_media: { type: "array", items: id(), nullable: true },
},
required: ["uuid", "latest"],
};
Expand Down
7 changes: 4 additions & 3 deletions packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"d3-scale-chromatic": "^3.0.0",
"jsonschema": "^1.4.1",
"mitt": "^3.0.0",
"pinia": "^2.0.17",
"pinia-plugin-persistedstate": "^2.1.1",
"@popperjs/core": "^2.11.5",
"primevue": "^3.15.0",
"primeicons": "^5.0.0",
Expand All @@ -33,9 +35,7 @@
"vue": "^3.2.37",
"vue-observe-visibility": "^1.0.0",
"vue-prism-editor": "^2.0.0-alpha.2",
"vue-router": "^4.1.3",
"vuex": "^4.0.2",
"vuex-persistedstate": "^4.1.0"
"vue-router": "^4.1.3"
},
"devDependencies": {
"@types/bootstrap": "^5.2.1",
Expand All @@ -54,6 +54,7 @@
"babel-core": "6.26.3",
"babel-loader": "^8.2.5",
"babel-plugin-prismjs": "^2.1.0",
"pinia-logger": "^1.3.2",
"typescript": "^4.7.4",
"webpack": "^5.74.0"
},
Expand Down
47 changes: 24 additions & 23 deletions packages/website/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ import { emitBusEvent, onBusEvent } from "./bus";
import { HttpClient } from "./Httpclient";
import { defineComponent } from "vue";
import { optimizedResize } from "./init";
import { useSettingsStore } from "./store/settings";
import { mapStores } from "pinia";
import { useUserStore } from "./store/store";
export default defineComponent({
components: {
appHeader,
},
computed: {
...mapStores(useUserStore),
loggedIn(): boolean {
return this.$store.getters.loggedIn;
return this.userStore.loggedIn;
},
},
watch: {
Expand All @@ -33,20 +37,19 @@ export default defineComponent({
this.loginState();
}
},
"$store.settings.notifications": {
handler() {
// FIXME: does not fire somehow on changes
if (this.$store.state.settings.notifications.newReleases.enabled) {
this.$store.dispatch("activateNewReleases");
},
mounted() {
const store = useSettingsStore();
store.$subscribe(
() => {
if (store.notifications.newReleases.enabled) {
store.activateNewReleases();
} else {
this.$store.dispatch("deactivateNewReleases");
store.deactivateNewReleases();
}
},
immediate: true,
deep: true,
},
},
mounted() {
{ immediate: true },
);
onBusEvent("refresh:externalUser", (data: string) => this.refreshExternalUser(data));
onBusEvent("reset:modal", () => this.closeModal());
Expand All @@ -56,20 +59,21 @@ export default defineComponent({
async created() {
if (this.loggedIn) {
await this.$store.dispatch("load");
await this.userStore.load();
} else {
await this.loginState();
}
},
methods: {
closeModal() {
this.$store.commit("resetModal", "login");
this.$store.commit("resetModal", "register");
this.$store.commit("resetModal", "addList");
this.$store.commit("resetModal", "addMedium");
this.$store.commit("resetModal", "error");
this.$store.commit("resetModal", "settings");
// TODO: modal thingis
// this.$store.commit("resetModal", "login");
// this.$store.commit("resetModal", "register");
// this.$store.commit("resetModal", "addList");
// this.$store.commit("resetModal", "addMedium");
// this.$store.commit("resetModal", "error");
// this.$store.commit("resetModal", "settings");
},
async loginState() {
Expand All @@ -82,10 +86,7 @@ export default defineComponent({
console.log(`Logged In: ${this.loggedIn} New User: `, newUser);
if (!this.loggedIn && newUser) {
await this.$store.dispatch("changeUser", {
user: newUser,
modal: "login",
});
await this.userStore.changeUser(newUser, "login");
} else {
throw Error();
}
Expand Down
Loading

0 comments on commit 0b34e1a

Please sign in to comment.