LFG !!!
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
import { RelayPool } from 'nostr-relaypool';
|
||||
|
||||
export function pool({ relays }: { relays: any }) {
|
||||
const createPool = new RelayPool(relays, { useEventCache: false, logSubscriptions: false });
|
||||
return createPool;
|
||||
}
|
||||
1
src/utils/ssr.tsx
Normal file
1
src/utils/ssr.tsx
Normal file
@@ -0,0 +1 @@
|
||||
export const isSSR = typeof window === 'undefined';
|
||||
@@ -25,7 +25,14 @@ export async function getAllRelays() {
|
||||
// get active account
|
||||
export async function getActiveAccount() {
|
||||
const db = await connect();
|
||||
return await db.select(`SELECT * FROM accounts LIMIT 1;`);
|
||||
const result = await db.select(`SELECT * FROM accounts LIMIT 1;`);
|
||||
return result[0];
|
||||
}
|
||||
|
||||
// get all accounts
|
||||
export async function getAccounts() {
|
||||
const db = await connect();
|
||||
return await db.select(`SELECT * FROM accounts`);
|
||||
}
|
||||
|
||||
// get all follows by account id
|
||||
@@ -71,3 +78,26 @@ export async function createCacheProfile(id, metadata) {
|
||||
const db = await connect();
|
||||
return await db.execute('INSERT OR IGNORE INTO cache_profiles (id, metadata) VALUES (?, ?);', [id, metadata]);
|
||||
}
|
||||
|
||||
// get cache profile
|
||||
export async function getCacheProfile(id) {
|
||||
const db = await connect();
|
||||
const result = await db.select(`SELECT metadata FROM cache_profiles WHERE id = "${id}"`);
|
||||
return result[0];
|
||||
}
|
||||
|
||||
// get note by id
|
||||
export async function getNoteByID(id) {
|
||||
const db = await connect();
|
||||
const result = await db.select(`SELECT * FROM cache_notes WHERE id = "${id}"`);
|
||||
return result[0];
|
||||
}
|
||||
|
||||
// create cache note
|
||||
export async function createCacheNote(data) {
|
||||
const db = await connect();
|
||||
return await db.execute(
|
||||
'INSERT OR IGNORE INTO cache_notes (id, pubkey, created_at, kind, content, tags, is_root) VALUES (?, ?, ?, ?, ?, ?, ?);',
|
||||
[data.id, data.pubkey, data.created_at, data.kind, data.content, JSON.stringify(data.tags), 0]
|
||||
);
|
||||
}
|
||||
|
||||
8
src/utils/tags.tsx
Normal file
8
src/utils/tags.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
export const tagsToArray = (arr) => {
|
||||
const newarr = [];
|
||||
// push item to newarr
|
||||
arr.forEach((item) => {
|
||||
newarr.push(item[1]);
|
||||
});
|
||||
return newarr;
|
||||
};
|
||||
Reference in New Issue
Block a user