diff --git a/preload.js b/preload.js index fef258d1c..57519c161 100644 --- a/preload.js +++ b/preload.js @@ -26,6 +26,9 @@ window.getNodeVersion = () => configAny.node_version; window.sessionFeatureFlags = { useOnionRequests: true, + useTestNet: Boolean( + process.env.NODE_APP_INSTANCE && process.env.NODE_APP_INSTANCE.includes('testnet') + ), }; window.versionInfo = { @@ -211,11 +214,14 @@ window.ReactDOM = require('react-dom'); window.clipboard = clipboard; -window.getSeedNodeList = () => [ - 'https://storage.seed1.loki.network:4433/', - 'https://storage.seed3.loki.network:4433/', - 'https://public.loki.foundation:4433/', -]; +window.getSeedNodeList = () => + window.sessionFeatureFlags.useTestNet + ? ['http://public.loki.foundation:38157'] + : [ + 'https://storage.seed1.loki.network:4433/', + 'https://storage.seed3.loki.network:4433/', + 'https://public.loki.foundation:4433/', + ]; const { locale: localFromEnv } = config; window.i18n = setupi18n(localFromEnv, localeMessages); diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 7e0cf307c..2d0080e2e 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1250,7 +1250,7 @@ export class ConversationModel extends Backbone.Model { public async setIsApproved(value: boolean, shouldCommit: boolean = true) { if (value !== this.isApproved()) { - window?.log?.info(`Setting ${ed25519Str(this.attributes.id)} isApproved to: ${value}`); + window?.log?.info(`Setting ${ed25519Str(this.id)} isApproved to: ${value}`); this.set({ isApproved: value, }); @@ -1263,7 +1263,7 @@ export class ConversationModel extends Backbone.Model { public async setDidApproveMe(value: boolean, shouldCommit: boolean = true) { if (value !== this.didApproveMe()) { - window?.log?.info(`Setting ${ed25519Str(this.attributes.id)} didApproveMe to: ${value}`); + window?.log?.info(`Setting ${ed25519Str(this.id)} didApproveMe to: ${value}`); this.set({ didApproveMe: value, }); diff --git a/ts/node/sql.ts b/ts/node/sql.ts index 5e9c0572c..1ffeafc19 100644 --- a/ts/node/sql.ts +++ b/ts/node/sql.ts @@ -1182,6 +1182,7 @@ function updateToLokiSchemaVersion17(currentVersion: number, db: BetterSqlite3.D function dropFtsAndTriggers(db: BetterSqlite3.Database) { console.info('dropping fts5 table'); + db.exec(` DROP TRIGGER IF EXISTS messages_on_insert; DROP TRIGGER IF EXISTS messages_on_delete; @@ -3466,6 +3467,8 @@ function cleanUpOldOpengroups() { const ourNumber = getItemById('number_id'); if (!ourNumber || !ourNumber.value) { + rebuildFtsTable(assertGlobalInstance()); + return; } const ourPubkey = ourNumber.value.split('.')[0]; diff --git a/ts/session/apis/snode_api/snodePool.ts b/ts/session/apis/snode_api/snodePool.ts index fe72ca71e..03d6573bb 100644 --- a/ts/session/apis/snode_api/snodePool.ts +++ b/ts/session/apis/snode_api/snodePool.ts @@ -9,7 +9,7 @@ import { ed25519Str } from '../../onions/onionPath'; import { OnionPaths } from '../../onions'; import { Onions, SnodePool } from '.'; import { SeedNodeAPI } from '../seed_node_api'; -import { useTestNet } from '../../types'; + /** * If we get less than this snode in a swarm, we fetch new snodes for this pubkey */ @@ -180,8 +180,7 @@ export async function getRandomSnodePool(): Promise> { */ // tslint:disable: function-name export async function TEST_fetchFromSeedWithRetriesAndWriteToDb() { - // tslint:disable-next-line: no-http-string - const seedNodes = useTestNet ? ['http://public.loki.foundation:38157'] : window.getSeedNodeList(); + const seedNodes = window.getSeedNodeList(); if (!seedNodes || !seedNodes.length) { window?.log?.error( diff --git a/ts/session/types/PubKey.ts b/ts/session/types/PubKey.ts index f1d0fa4dc..02c1b64e3 100644 --- a/ts/session/types/PubKey.ts +++ b/ts/session/types/PubKey.ts @@ -1,8 +1,7 @@ import { fromHexToArray } from '../utils/String'; -export const useTestNet = process.env.NODE_APP_INSTANCE?.includes('testnet'); - -export const getStoragePubKey = (key: string) => (useTestNet ? key.substring(2) : key); +export const getStoragePubKey = (key: string) => + window.sessionFeatureFlags.useTestNet ? key.substring(2) : key; export class PubKey { public static readonly PUBKEY_LEN = 66; diff --git a/ts/window.d.ts b/ts/window.d.ts index d9064755a..df99dc20e 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -37,6 +37,7 @@ declare global { log: any; sessionFeatureFlags: { useOnionRequests: boolean; + useTestNet: boolean; }; SessionSnodeAPI: SessionSnodeAPI; onLogin: any;