Fix lint issues
And disable eslint when building in prod mode Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -37,11 +37,15 @@ export function saveActorData(obj: IPerson): void {
|
||||
}
|
||||
|
||||
export function deleteUserData(): void {
|
||||
[AUTH_USER_ID, AUTH_USER_EMAIL, AUTH_ACCESS_TOKEN, AUTH_REFRESH_TOKEN, AUTH_USER_ROLE].forEach(
|
||||
(key) => {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
);
|
||||
[
|
||||
AUTH_USER_ID,
|
||||
AUTH_USER_EMAIL,
|
||||
AUTH_ACCESS_TOKEN,
|
||||
AUTH_REFRESH_TOKEN,
|
||||
AUTH_USER_ROLE,
|
||||
].forEach((key) => {
|
||||
localStorage.removeItem(key);
|
||||
});
|
||||
}
|
||||
|
||||
export class NoIdentitiesException extends Error {}
|
||||
@@ -62,7 +66,9 @@ export async function changeIdentity(
|
||||
* then fetch the current identities to set in cache
|
||||
* the current identity used
|
||||
*/
|
||||
export async function initializeCurrentActor(apollo: ApolloClient<any>): Promise<void> {
|
||||
export async function initializeCurrentActor(
|
||||
apollo: ApolloClient<any>
|
||||
): Promise<void> {
|
||||
const actorId = localStorage.getItem(AUTH_USER_ACTOR_ID);
|
||||
|
||||
const result = await apollo.query({
|
||||
@@ -75,14 +81,17 @@ export async function initializeCurrentActor(apollo: ApolloClient<any>): Promise
|
||||
throw new NoIdentitiesException();
|
||||
}
|
||||
const activeIdentity =
|
||||
identities.find((identity: IPerson) => identity.id === actorId) || (identities[0] as IPerson);
|
||||
identities.find((identity: IPerson) => identity.id === actorId) ||
|
||||
(identities[0] as IPerson);
|
||||
|
||||
if (activeIdentity) {
|
||||
await changeIdentity(apollo, activeIdentity);
|
||||
}
|
||||
}
|
||||
|
||||
export async function logout(apollo: ApolloClient<NormalizedCacheObject>): Promise<void> {
|
||||
export async function logout(
|
||||
apollo: ApolloClient<NormalizedCacheObject>
|
||||
): Promise<void> {
|
||||
await apollo.mutate({
|
||||
mutation: UPDATE_CURRENT_USER_CLIENT,
|
||||
variables: {
|
||||
|
||||
@@ -8,10 +8,14 @@ import langs from "../i18n/langs.json";
|
||||
const DEFAULT_LOCALE = "en_US";
|
||||
|
||||
let language =
|
||||
localStorage.getItem(USER_LOCALE) || (document.documentElement.getAttribute("lang") as string);
|
||||
localStorage.getItem(USER_LOCALE) ||
|
||||
(document.documentElement.getAttribute("lang") as string);
|
||||
language =
|
||||
language ||
|
||||
((window.navigator as any).userLanguage || window.navigator.language).replace(/-/, "_");
|
||||
((window.navigator as any).userLanguage || window.navigator.language).replace(
|
||||
/-/,
|
||||
"_"
|
||||
);
|
||||
export const locale =
|
||||
language && Object.prototype.hasOwnProperty.call(langs, language)
|
||||
? language
|
||||
@@ -71,7 +75,9 @@ export async function loadLanguageAsync(lang: string): Promise<string> {
|
||||
}
|
||||
// If the language hasn't been loaded yet
|
||||
const newMessages = await import(
|
||||
/* webpackChunkName: "lang-[request]" */ `@/i18n/${vueI18NfileForLanguage(lang)}.json`
|
||||
/* webpackChunkName: "lang-[request]" */ `@/i18n/${vueI18NfileForLanguage(
|
||||
lang
|
||||
)}.json`
|
||||
);
|
||||
i18n.setLocaleMessage(lang, newMessages.default);
|
||||
loadedLanguages.push(lang);
|
||||
@@ -82,7 +88,10 @@ loadLanguageAsync(locale);
|
||||
|
||||
export function formatList(list: string[]): string {
|
||||
if (window.Intl && Intl.ListFormat) {
|
||||
const formatter = new Intl.ListFormat(undefined, { style: "long", type: "conjunction" });
|
||||
const formatter = new Intl.ListFormat(undefined, {
|
||||
style: "long",
|
||||
type: "conjunction",
|
||||
});
|
||||
return formatter.format(list);
|
||||
}
|
||||
return list.join(",");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IMedia } from "@/types/media.model";
|
||||
|
||||
export async function buildFileFromIMedia(obj: IMedia | null | undefined): Promise<File | null> {
|
||||
export async function buildFileFromIMedia(
|
||||
obj: IMedia | null | undefined
|
||||
): Promise<File | null> {
|
||||
if (!obj) return Promise.resolve(null);
|
||||
|
||||
const response = await fetch(obj.url);
|
||||
@@ -27,7 +29,9 @@ export function buildFileVariable(
|
||||
};
|
||||
}
|
||||
|
||||
export function readFileAsync(file: File): Promise<string | ArrayBuffer | null> {
|
||||
export function readFileAsync(
|
||||
file: File
|
||||
): Promise<string | ArrayBuffer | null> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
|
||||
@@ -12,7 +12,10 @@ function convertToUsername(value: string | null): string {
|
||||
.replace(/[^a-z0-9_]/g, "");
|
||||
}
|
||||
|
||||
function autoUpdateUsername(actor: IActor, newDisplayName: string | null): IActor {
|
||||
function autoUpdateUsername(
|
||||
actor: IActor,
|
||||
newDisplayName: string | null
|
||||
): IActor {
|
||||
const actor2 = { ...actor };
|
||||
const oldUsername = convertToUsername(actor.name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user