Skip to content

Commit

Permalink
fix deepsource
Browse files Browse the repository at this point in the history
  • Loading branch information
Izobov committed Nov 21, 2024
1 parent 6a6b9ad commit fcc71c5
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 30 deletions.
10 changes: 5 additions & 5 deletions src/lib/components/page/profile/pupblication/editor/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ export async function upsert({ editor, title, author, reload = false, showLoader
| undefined, editor: Editor, title: string, author: AuthorsAuthorsMain, reload?: boolean, showLoaders?: boolean, id?: number
})
{
const v = DOMPurify.sanitize(editor.getHTML());
const t = DOMPurify.sanitize(title);
const sanitizedValue = DOMPurify.sanitize(editor.getHTML());
const sanitizedTitle = DOMPurify.sanitize(title);
const images = getAllImages(editor);

const { seo, tags } = create_article_store.get();

const loadingId = showLoaders && infoMessages.add({ type: "loading", text: translations?.saving || "Saving article..." });
const res = await postv2("/api/data/author/article", {
content: v,
title: t,
content: sanitizedValue,
title: sanitizedTitle,
id,
author_id: author.id,
tags,
Expand Down Expand Up @@ -101,7 +101,7 @@ export async function publish({ id, status, sportstack, redirect = true, transla
const loadingId = infoMessages.add({ type: "loading", text: translations?.saving || `${status} article...` });
const res = await fetch(`/api/data/author/article`, {
method: "PUT",
body: JSON.stringify({ id: id, status, uid: sportstack.uid })
body: JSON.stringify({ id, status, uid: sportstack.uid })
});
infoMessages.remove(loadingId);
const data = await res.json();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/section/authors/common_ui/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export async function fetchArticlesBySportstack({ permalink = "", page = 0, opti
url = `/api/data/author/sportstack?permalink=${permalink}&page=${page}`;
if (options)
{
Object.entries(options).forEach(([key, value]) => url += `&${key}=${value}`);
Object.entries(options).forEach(([key, value]) => { url += `&${key}=${value}` });
}
const /**
* @description
Expand Down
2 changes: 1 addition & 1 deletion src/lib/firebase/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import userBetarenaSettings from '$lib/store/user-settings.js';
import { dlog, dlogv2 } from '$lib/utils/debug.js';
import { checkNull } from '$lib/utils/miscellenous.js';
import { DataSnapshot, onValue, ref, type DatabaseReference, type Unsubscribe } from 'firebase/database';
import { ref as storageRef, deleteObject, getDownloadURL, uploadString } from "firebase/storage"
import { ref as storageRef, getDownloadURL, uploadString } from "firebase/storage"
import { arrayRemove, arrayUnion, doc, DocumentReference, getDoc, increment, onSnapshot, updateDoc } from 'firebase/firestore';
import { getTargetRealDbData } from './firebase.actions.js';
import { db_firestore, db_real, storage } from './init';
Expand Down
5 changes: 2 additions & 3 deletions src/lib/sveltekit/endpoint/sportstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { IPageAuthorAuthorData, IPageAuthorProfileData, IPageAuthorSportsta
import { json, type RequestEvent } from '@sveltejs/kit';
import { Betarena_User_Class } from '@betarena/scores-lib/dist/classes/class.betarena-user.js';
import type { IBetarenaUser } from '@betarena/scores-lib/types/_FIREBASE_.js';
import { ITableAuthorAuthorQuery2Out, ITableAuthorAuthorQuery2Var, TableAuthorAuthorQuery2 } from '@betarena/scores-lib/dist/graphql/v8/table.authors.authors.js';
import { preloadExitLogic } from '$lib/utils/navigation.js';
import { ERROR_CODE_INVALID } from '$lib/utils/debug.js';

Expand Down Expand Up @@ -46,8 +45,8 @@ export async function main

let limit, offset;

if (limitSearch) limit = +limitSearch;
if (offsetSearch) offset = +offsetSearch;
if (limitSearch) limit = Number(limitSearch);
if (offsetSearch) offset = Number(offsetSearch);

// ╭──────────────────────────────────────────────────────────────────╮
// │ NOTE: │
Expand Down
3 changes: 1 addition & 2 deletions src/lib/utils/sveltekitWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export async function gotoSW
* 💠 [optional] Target `url` to navigate to.
* @returns { Promise < void > }
*/
export async function submitWrapper({ successMessage = "Success!", errorMessage = "An error occurred.", reset = false, cbAfter }: { successMessage?: string, errorMessage?: string, reset?: boolean, cbAfter?: ({ update, result }) => void } = {})
export function submitWrapper({ successMessage = "Success!", errorMessage = "An error occurred.", reset = false, cbAfter }: { successMessage?: string, errorMessage?: string, reset?: boolean, cbAfter?: ({ update, result }) => void } = {})
{
const loadingId = infoMessages.add({
type: "loading",
Expand All @@ -81,7 +81,6 @@ export async function submitWrapper({ successMessage = "Success!", errorMessage
return async (e) =>
{
infoMessages.remove(loadingId);
console.log("RESPONSE: ", e)
if (e.result.type === "success")
{
infoMessages.add({
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(scores)/u/author/article/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { AuthorsAuthorsMain } from '@betarena/scores-lib/types/v8/_HASURA-0
import { _GraphQL } from '@betarena/scores-lib/dist/classes/_graphql.js';
import type { PageServerLoad } from '../create/[lang=lang]/$types.js';

export const load = (async ({ locals, fetch }) =>
export const load = (({ locals, fetch }) =>
{
const uid = locals.uid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const load: PageLoad = async ({ url }) =>
{
if (id)
{
const res = await entryProfileTabAuthorArticleDraftGet({ numArticleId: +id }) as any;
const res = await entryProfileTabAuthorArticleDraftGet({ numArticleId: Number(id) }) as any;
article = res?.article || article;
}
return { article }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export const load = (async ({ fetch, params }) =>
response: any = {}
;

// if (!isUrlValid)
// preloadExitLogic
// (
// 0,
// '(authors)',
// ERROR_CODE_INVALID
// );
// ;
if (!isUrlValid)
preloadExitLogic
(
0,
'(authors)',
ERROR_CODE_INVALID
);
;
const res = await fetch(`/api/data/author/article?permalink=${permalink}`);
const article = await res.json() as IPageAuhtorArticleDataFinal;
return { ...article };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { AuthorsAuthorsMain } from '@betarena/scores-lib/types/v8/_HASURA-0.js';
import { _GraphQL } from '@betarena/scores-lib/dist/classes/_graphql.js';
import type { LayoutServerLoad } from '.svelte-kit/types/src/routes/(scores)/u/author/publication/[permalink]/$types.js';
import { getSportstackByPermalink } from '$lib/sveltekit/endpoint/sportstack.js';
import { preloadExitLogic } from '$lib/utils/navigation.js';
import { ERROR_CODE_UNAUTHORIZED, PAGE_UNAUTHORIZED_MSG } from '$lib/utils/debug.js';
import { LayoutServerLoad } from './$types.js';

export const load: LayoutServerLoad = (async ({ locals, fetch, params }) =>
{
Expand Down
2 changes: 1 addition & 1 deletion src/routes/api/data/author/article/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const POST: RequestHandler = async ({ request, locals }) =>
{
if (!locals.uid) throw error(401, { message: 'Unauthorized' } as App.Error);
const body = await request.json();
let { content, title, author_id, images, id, seo, tags, uid, article, lang } = body;
const { content, title, author_id, images, id, seo, tags, uid, article, lang } = body;

if (locals.uid !== uid) return json({ success: false, message: "Not an owner" });
let data = article;
Expand Down
13 changes: 7 additions & 6 deletions src/routes/api/data/author/sportstack/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Actions, fail } from '@sveltejs/kit';
import { entryProfileTabAuthorSportstackUpsert, entryProfileTabAuthorValidateSportstackUsername } from '@betarena/scores-lib/dist/functions/v8/profile.main.js';
import type { AuthorsAuthorsDataJSONSchema, AuthorsAuthorsMain } from '@betarena/scores-lib/types/v8/_HASURA-0.js';
import type { AuthorsAuthorsMain } from '@betarena/scores-lib/types/v8/_HASURA-0.js';
import { getSportstackByPermalink } from '$lib/sveltekit/endpoint/sportstack.js';

export const actions: Actions = {
Expand All @@ -10,8 +10,9 @@ export const actions: Actions = {

const { user } = locals;
if (!user)
return fail(401, { error: true, message: 'Unauthorized', reason: 'No user in locals' });
{
return fail(401, { error: true, message: 'Unauthorized', reason: 'No user in locals' });

}
const uid = JSON.parse(user)['user-uid'];
if (!uid)
Expand All @@ -25,12 +26,12 @@ export const actions: Actions = {
const formData = await request.formData();
const dataObject = Object.fromEntries(formData.entries());
const { id, username, about, permalink, avatar } = dataObject as { id: number } & AuthorsAuthorsMain["data"];
const s = await getSportstackByPermalink(permalink);
if (!s)
const isSportstackExist = await getSportstackByPermalink(permalink);
if (!isSportstackExist)
{
return fail(400, { error: true, message: "Sportstack dosen't exists" });
}
const { sportstacks } = s;
const { sportstacks } = isSportstackExist;
await entryProfileTabAuthorSportstackUpsert({
id,
uid,
Expand All @@ -56,8 +57,8 @@ export const actions: Actions = {
{
const { user } = locals;
if (!user)
return fail(401, { error: true, message: 'Unauthorized', reason: 'No user in locals' });
{
return fail(401, { error: true, message: 'Unauthorized', reason: 'No user in locals' });
}
const uid = JSON.parse(user)['user-uid'];
if (!uid)
Expand Down

0 comments on commit fcc71c5

Please sign in to comment.