From 80d0925ed7b601dc4fe07f65591e66a69f7ba422 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Sun, 10 May 2020 07:10:32 +0530 Subject: [PATCH] :bug: Fixed #731 --- functions/fb.js | 56 ++++++++++++++++++++++++------------------------- pages/index.vue | 36 ++++++++++++++++++------------- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/functions/fb.js b/functions/fb.js index 2a5f8b5d7..77d50bc29 100644 --- a/functions/fb.js +++ b/functions/fb.js @@ -21,7 +21,7 @@ const usersCollection = firebase.firestore().collection("users") // the shared state object that any vue component // can get access to export const fb = { - currentUser: {}, + currentUser: null, currentFeeds: [], currentSettings: [], currentHistory: [], @@ -40,15 +40,15 @@ export const fb = { .doc(fb.currentUser.uid) .collection("feeds") .add(dt) - .catch(e => console.error("error inserting", dt, e)) + .catch((e) => console.error("error inserting", dt, e)) }, - deleteFeed: id => { + deleteFeed: (id) => { usersCollection .doc(fb.currentUser.uid) .collection("feeds") .doc(id) .delete() - .catch(e => console.error("error deleting", id, e)) + .catch((e) => console.error("error deleting", id, e)) }, writeSettings: async (setting, value) => { const st = { @@ -64,23 +64,23 @@ export const fb = { .collection("settings") .doc(setting) .set(st) - .catch(e => console.error("error updating", st, e)) + .catch((e) => console.error("error updating", st, e)) }, - writeHistory: async entry => { + writeHistory: async (entry) => { const hs = entry usersCollection .doc(fb.currentUser.uid) .collection("history") .add(hs) - .catch(e => console.error("error inserting", hs, e)) + .catch((e) => console.error("error inserting", hs, e)) }, - deleteHistory: entry => { + deleteHistory: (entry) => { usersCollection .doc(fb.currentUser.uid) .collection("history") .doc(entry.id) .delete() - .catch(e => console.error("error deleting", entry, e)) + .catch((e) => console.error("error deleting", entry, e)) }, clearHistory: () => { usersCollection @@ -88,7 +88,7 @@ export const fb = { .collection("history") .get() .then(({ docs }) => { - docs.forEach(e => fb.deleteHistory(e)) + docs.forEach((e) => fb.deleteHistory(e)) }) }, toggleStar: (entry, value) => { @@ -97,9 +97,9 @@ export const fb = { .collection("history") .doc(entry.id) .update({ star: value }) - .catch(e => console.error("error deleting", entry, e)) + .catch((e) => console.error("error deleting", entry, e)) }, - writeCollections: async collection => { + writeCollections: async (collection) => { const cl = { updatedOn: new Date(), author: fb.currentUser.uid, @@ -112,9 +112,9 @@ export const fb = { .collection("collections") .doc("sync") .set(cl) - .catch(e => console.error("error updating", cl, e)) + .catch((e) => console.error("error updating", cl, e)) }, - writeEnvironments: async environment => { + writeEnvironments: async (environment) => { const ev = { updatedOn: new Date(), author: fb.currentUser.uid, @@ -127,15 +127,15 @@ export const fb = { .collection("environments") .doc("sync") .set(ev) - .catch(e => console.error("error updating", ev, e)) + .catch((e) => console.error("error updating", ev, e)) }, } // When a user logs in or out, save that in the store -firebase.auth().onAuthStateChanged(user => { +firebase.auth().onAuthStateChanged((user) => { if (user) { fb.currentUser = user - fb.currentUser.providerData.forEach(profile => { + fb.currentUser.providerData.forEach((profile) => { let us = { updatedOn: new Date(), provider: profile.providerId, @@ -147,16 +147,16 @@ firebase.auth().onAuthStateChanged(user => { usersCollection .doc(fb.currentUser.uid) .set(us) - .catch(e => console.error("error updating", us, e)) + .catch((e) => console.error("error updating", us, e)) }) usersCollection .doc(fb.currentUser.uid) .collection("feeds") .orderBy("createdOn", "desc") - .onSnapshot(feedsRef => { + .onSnapshot((feedsRef) => { const feeds = [] - feedsRef.forEach(doc => { + feedsRef.forEach((doc) => { const feed = doc.data() feed.id = doc.id feeds.push(feed) @@ -167,9 +167,9 @@ firebase.auth().onAuthStateChanged(user => { usersCollection .doc(fb.currentUser.uid) .collection("settings") - .onSnapshot(settingsRef => { + .onSnapshot((settingsRef) => { const settings = [] - settingsRef.forEach(doc => { + settingsRef.forEach((doc) => { const setting = doc.data() setting.id = doc.id settings.push(setting) @@ -180,9 +180,9 @@ firebase.auth().onAuthStateChanged(user => { usersCollection .doc(fb.currentUser.uid) .collection("history") - .onSnapshot(historyRef => { + .onSnapshot((historyRef) => { const history = [] - historyRef.forEach(doc => { + historyRef.forEach((doc) => { const entry = doc.data() entry.id = doc.id history.push(entry) @@ -193,9 +193,9 @@ firebase.auth().onAuthStateChanged(user => { usersCollection .doc(fb.currentUser.uid) .collection("collections") - .onSnapshot(collectionsRef => { + .onSnapshot((collectionsRef) => { const collections = [] - collectionsRef.forEach(doc => { + collectionsRef.forEach((doc) => { const collection = doc.data() collection.id = doc.id collections.push(collection) @@ -206,9 +206,9 @@ firebase.auth().onAuthStateChanged(user => { usersCollection .doc(fb.currentUser.uid) .collection("environments") - .onSnapshot(environmentsRef => { + .onSnapshot((environmentsRef) => { const environments = [] - environmentsRef.forEach(doc => { + environmentsRef.forEach((doc) => { const environment = doc.data() environment.id = doc.id environments.push(environment) diff --git a/pages/index.vue b/pages/index.vue index 8ad639e55..a8e110c6c 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -263,13 +263,13 @@ + class="icon" + @click="prettifyRequestBody()" + v-tooltip="$t('prettify_body')" + v-if="rawInput && this.contentType.endsWith('json')" + > + assistant + @@ -858,8 +858,8 @@
  • -
  • @@ -1329,7 +1333,11 @@ import { tokenRequest, oauthRedirect } from "../assets/js/oauth" import { sendNetworkRequest } from "../functions/network" import { fb } from "../functions/fb" import { getEditorLangForMimeType } from "~/functions/editorutils" -import { hasPathParams, addPathParamsToVariables, getQueryParams } from "../functions/requestParams.js" +import { + hasPathParams, + addPathParamsToVariables, + getQueryParams, +} from "../functions/requestParams.js" import { parseUrlAndPath } from "../functions/utils/uri.js" const statusCategories = [ { @@ -2193,7 +2201,7 @@ export default { } })() } catch (error) { - console.error(error) + console.log(error) if (error.response) { this.response.headers = error.response.headers this.response.status = error.response.status @@ -2357,7 +2365,7 @@ export default { url: window.location.href, }) .then(() => {}) - .catch(console.error) + .catch(() => {}) } else { const dummy = document.createElement("input") document.body.appendChild(dummy)