Skip to content

Commit

Permalink
Hopefully fix namespace sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Apr 3, 2024
1 parent a29f256 commit 81be8ac
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 220 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ provideLocal(
sessionExists: () =>
Promise.resolve(typeof Cookies.get("token") === "string"),
},
})
}),
);
const { loadUser } = collection();
const { isLoadingUser, user } = storeToRefs(collection());
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/Bookstores.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ import { MapboxMap, MapboxMarker, MapboxPopup } from "vue-mapbox-ts";
import { SimpleBookstore } from "~dm-types/SimpleBookstore";
const { bookstoreServices } = injectLocal("dmSocket") as ReturnType<
typeof useDmSocket
>;
const {
bookstore: { services: bookstoreServices },
} = injectLocal("dmSocket") as ReturnType<typeof useDmSocket>;
const { fetchStats } = users();
const { stats: userStats } = storeToRefs(users());
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/StorySearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ const emit = defineEmits<{
}>();
const { conditions } = useCondition();
const { coaServices } = injectLocal("dmSocket") as ReturnType<
typeof useDmSocket
>;
const {
coa: { services: coaServices },
} = injectLocal("dmSocket") as ReturnType<typeof useDmSocket>;
const { findInCollection } = isPublic ? publicCollection() : collection();
const { issues } = storeToRefs(collection());
Expand Down
68 changes: 32 additions & 36 deletions apps/web/src/composables/useDmSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,67 +46,63 @@ export default (options: {

return {
options,
publicCollectionServices: addNamespace<PublicCollectionServices>(
publicCollection: addNamespace<PublicCollectionServices>(
PublicCollectionServices.namespaceEndpoint,
{ onConnectError },
),
loginServices: addNamespace<LoginServices>(
LoginServices.namespaceEndpoint,
{ onConnectError },
{ onConnectError }
),
login: addNamespace<LoginServices>(LoginServices.namespaceEndpoint, {
onConnectError,
}),

bookcaseServices: addNamespace<BookcaseServices>(
bookcase: addNamespace<BookcaseServices>(
BookcaseServices.namespaceEndpoint,
{ onConnectError, session },
),
statsServices: addNamespace<StatsServices>(
StatsServices.namespaceEndpoint,
{ onConnectError, session },
{ onConnectError, session }
),
authServices: addNamespace<AuthServices>(AuthServices.namespaceEndpoint, {
stats: addNamespace<StatsServices>(StatsServices.namespaceEndpoint, {
onConnectError,
session,
}),
edgeCreatorServices: addNamespace<EdgeCreatorServices>(
auth: addNamespace<AuthServices>(AuthServices.namespaceEndpoint, {
onConnectError,
session,
}),
edgeCreator: addNamespace<EdgeCreatorServices>(
EdgeCreatorServices.namespaceEndpoint,
{ onConnectError },
{ onConnectError }
),
presentationTextServices: addNamespace<PresentationTextServices>(
presentationText: addNamespace<PresentationTextServices>(
PresentationTextServices.namespaceEndpoint,
{ onConnectError },
),
edgesServices: addNamespace<EdgesServices>(
EdgesServices.namespaceEndpoint,
{ onConnectError },
{ onConnectError }
),
coaServices: addNamespace<CoaServices>(CoaServices.namespaceEndpoint, {
edges: addNamespace<EdgesServices>(EdgesServices.namespaceEndpoint, {
onConnectError,
}),
coa: addNamespace<CoaServices>(CoaServices.namespaceEndpoint, {
onConnectError,
cache: {
ttl: until4am(),
},
}),
globalStatsServices: addNamespace<GlobalStatsServices>(
globalStats: addNamespace<GlobalStatsServices>(
GlobalStatsServices.namespaceEndpoint,
{ onConnectError },
{ onConnectError }
// {
// ttl: oneHour(),
// },
),
eventsServices: addNamespace<EventsServices>(
EventsServices.namespaceEndpoint,
{ onConnectError },
),
bookstoreServices: addNamespace<BookstoreServices>(
events: addNamespace<EventsServices>(EventsServices.namespaceEndpoint, {
onConnectError,
}),
bookstore: addNamespace<BookstoreServices>(
BookstoreServices.namespaceEndpoint,
{ onConnectError },
{ onConnectError }
),
collectionServices: addNamespace<CollectionServices>(
collection: addNamespace<CollectionServices>(
CollectionServices.namespaceEndpoint,
{ onConnectError, session },
),
coverIdServices: addNamespace<CoverIdServices>(
CoverIdServices.namespaceEndpoint,
{ onConnectError },
{ onConnectError, session }
),
coverId: addNamespace<CoverIdServices>(CoverIdServices.namespaceEndpoint, {
onConnectError,
}),
};
};
6 changes: 3 additions & 3 deletions apps/web/src/pages/admin/edges/progress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ const bookcaseTextures = $ref({
bookshelf: "bois/KNOTTY PINE",
});
const { edgesServices } = injectLocal("dmSocket") as ReturnType<
typeof useDmSocket
>;
const {
edges: { services: edgesServices },
} = injectLocal("dmSocket") as ReturnType<typeof useDmSocket>;
const { fetchPublicationNames, fetchIssueNumbers } = coa();
const { publicationNames, issueNumbers } = storeToRefs(coa());
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ let username = $ref("" as string);
let error = $ref(null as string | null);
let password = $ref("" as string);
const { collectionServices } = injectLocal("dmSocket") as ReturnType<
typeof useDmSocket
>;
const {
collection: { services: collectionServices },
} = injectLocal("dmSocket") as ReturnType<typeof useDmSocket>;
const login = async () => {
await userLogin(
Expand Down
21 changes: 10 additions & 11 deletions apps/web/src/pages/stats/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@
<script setup lang="ts">
import { QuotedIssue } from "~dm-types/QuotedIssue";
const { globalStatsServices } = injectLocal("dmSocket") as ReturnType<
typeof useDmSocket
>;
const {
globalStats: { services: globalStatsServices },
} = injectLocal("dmSocket") as ReturnType<typeof useDmSocket>;
const { getConditionLabel } = useCondition();
Expand All @@ -180,14 +180,13 @@ const { totalPerPublication, quotedIssues, quotationSum, user } =
const { fetchPublicationNames, fetchIssueQuotations } = coa();
const { publicationNames } = storeToRefs(coa());
const quotedIssuesForCollection = $computed(
() =>
quotedIssues.value?.sort(
(
{ estimationGivenCondition: estimation1 },
{ estimationGivenCondition: estimation2 }
) => Math.sign(estimation2 - estimation1)
)
const quotedIssuesForCollection = $computed(() =>
quotedIssues.value?.sort(
(
{ estimationGivenCondition: estimation1 },
{ estimationGivenCondition: estimation2 }
) => Math.sign(estimation2 - estimation1)
)
);
const quotationFields = [
{ key: "issue", label: $t("Numéro") },
Expand Down
18 changes: 12 additions & 6 deletions apps/web/src/stores/bookcase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ export interface BookcaseEdgeWithPopularity extends BookcaseEdge {

export const bookcase = defineStore("bookcase", () => {
const route = useRoute();

console.log("bookcase store");
const {
bookcase: { services: bookcaseServices },
} = injectLocal("dmSocket") as ReturnType<typeof useDmSocket>;

const loadedSprites = ref({} as { [key: string]: string }),
isPrivateBookcase = ref(false as boolean),
isUserNotExisting = ref(false as boolean),
bookcaseUsername = ref(null as string | null),
bookcase = ref(null as BookcaseEdge[] | null),
bookcaseOptions = ref(
null as EventReturnType<BookcaseServices["getBookcaseOptions"]> | null,
null as EventReturnType<BookcaseServices["getBookcaseOptions"]> | null
),
bookcaseOrder = ref(null as string[] | null),
edgeIndexToLoad = ref(0 as number),
isSharedBookcase = computed(
(): boolean => route.params.username !== undefined,
(): boolean => route.params.username !== undefined
),
bookcaseWithPopularities = computed(
(): BookcaseEdgeWithPopularity[] | null =>
Expand All @@ -42,7 +48,7 @@ export const bookcase = defineStore("bookcase", () => {
: collection().popularIssuesInCollection?.[issueCode] || 0,
};
})) ||
null,
null
),
addLoadedSprite = ({
spritePath,
Expand All @@ -59,7 +65,7 @@ export const bookcase = defineStore("bookcase", () => {
loadBookcase = async () => {
if (!bookcase.value) {
const response = await bookcaseServices.getBookcase(
bookcaseUsername.value!,
bookcaseUsername.value!
);
switch (response.error) {
case "Forbidden":
Expand All @@ -76,7 +82,7 @@ export const bookcase = defineStore("bookcase", () => {
loadBookcaseOptions = async () => {
if (!bookcaseOptions.value) {
const response = await bookcaseServices.getBookcaseOptions(
bookcaseUsername.value!,
bookcaseUsername.value!
);
if ("error" in response) {
console.error(response.error);
Expand All @@ -91,7 +97,7 @@ export const bookcase = defineStore("bookcase", () => {
loadBookcaseOrder = async () => {
if (!bookcaseOrder.value) {
const response = await bookcaseServices.getBookcaseOrder(
bookcaseUsername.value!,
bookcaseUsername.value!
);
if ("error" in response) {
console.error(response.error);
Expand Down
Loading

0 comments on commit 81be8ac

Please sign in to comment.