From 772ee7f68ad4f144b7b33e137d4795cf0e4ee4a9 Mon Sep 17 00:00:00 2001 From: davay Date: Mon, 24 Apr 2023 23:15:27 +0700 Subject: [PATCH] fix: usePass becomes useAuth. First stage - move --- src/auth/composables.ts | 1 + src/{user/usePass.ts => auth/useAuth.ts} | 2 +- src/components.ts | 2 +- src/composables.ts | 1 + src/gun/useGun.ts | 14 +++----------- src/post/action/PostActionBan.vue | 4 +++- src/user/composables.ts | 1 - src/user/index.vue | 2 +- 8 files changed, 11 insertions(+), 16 deletions(-) create mode 100644 src/auth/composables.ts rename src/{user/usePass.ts => auth/useAuth.ts} (99%) diff --git a/src/auth/composables.ts b/src/auth/composables.ts new file mode 100644 index 000000000..9cc5b64bd --- /dev/null +++ b/src/auth/composables.ts @@ -0,0 +1 @@ +export * from './useAuth' \ No newline at end of file diff --git a/src/user/usePass.ts b/src/auth/useAuth.ts similarity index 99% rename from src/user/usePass.ts rename to src/auth/useAuth.ts index 3aa43b076..386e0d84d 100644 --- a/src/user/usePass.ts +++ b/src/auth/useAuth.ts @@ -1,6 +1,6 @@ /** * Manage user's password and credentials - * @module Pass + * @module Auth * @group Users */ diff --git a/src/components.ts b/src/components.ts index a0c8772d1..61e5a804a 100644 --- a/src/components.ts +++ b/src/components.ts @@ -7,7 +7,6 @@ import 'floating-vue/dist/style.css' import { createApp } from "vue"; import * as Vue from 'vue' -import { gun } from './composables' import * as components from './all-components' @@ -36,6 +35,7 @@ export function createGunVueApp( App.use(GunVuePlugin) init(App) App.mount(tag) + return { Vue, App } } diff --git a/src/composables.ts b/src/composables.ts index 9d6886ab4..b3d515e14 100644 --- a/src/composables.ts +++ b/src/composables.ts @@ -1,4 +1,5 @@ export * from "./account/composables" +export * from "./auth/composables" export * from "./cast/composables" export * from "./chat/composables" export * from "./crypto/composables" diff --git a/src/gun/useGun.ts b/src/gun/useGun.ts index 95416bec9..f2b673737 100644 --- a/src/gun/useGun.ts +++ b/src/gun/useGun.ts @@ -17,7 +17,6 @@ import "gun/lib/webrtc"; import { relay } from './useRelay' -import { shallowReactive } from 'vue'; // https://github.com/amark/gun/wiki/volunteer.dht @@ -26,11 +25,6 @@ import { shallowReactive } from 'vue'; /** The main Gun instance for database operations */ export let gun: IGunInstance; -/** Secondary Gun instance for key management */ -let gun2: IGunInstance; - -export const gunInstances = shallowReactive([]) - /** * Instantiate a Gun instance for DB manipulations * @example @@ -46,7 +40,6 @@ export function useGun(options: GunOptions = { localStorage: false }): IGunInsta } console.log(opts.peers) gun = Gun(opts); - gunInstances.push(gun) } return gun; } @@ -56,10 +49,9 @@ export function useGun(options: GunOptions = { localStorage: false }): IGunInsta */ export function useGun2(options: object = { localStorage: false }): IGunInstance { - if (!gun2) { - gun2 = Gun({ peers: [relay.peer], ...options }); - gunInstances.push(gun2) - } + + const gun2 = Gun({ peers: [relay.peer], ...options }); + return gun2; } diff --git a/src/post/action/PostActionBan.vue b/src/post/action/PostActionBan.vue index 631dca2be..1b468b567 100644 --- a/src/post/action/PostActionBan.vue +++ b/src/post/action/PostActionBan.vue @@ -1,6 +1,6 @@