mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
WIP sql.js
This commit is contained in:
parent
9f3379e702
commit
70ee8cefdc
8 changed files with 544 additions and 455 deletions
|
@ -1,6 +0,0 @@
|
|||
module.exports = {
|
||||
rules: {
|
||||
// On the node.js side, we're still using console.log
|
||||
'no-console': 'off',
|
||||
},
|
||||
};
|
|
@ -282,7 +282,6 @@
|
|||
"stylesheets/*.css",
|
||||
"!js/register.js",
|
||||
"js/views/standalone_registration_view.js",
|
||||
"app/*",
|
||||
"preload.js",
|
||||
"about_preload.js",
|
||||
"settings_preload.js",
|
||||
|
|
|
@ -39,12 +39,14 @@ async function getMediaGalleryProps(
|
|||
}> {
|
||||
// We fetch more documents than media as they don’t require to be loaded
|
||||
// into memory right away. Revisit this once we have infinite scrolling:
|
||||
const rawMedia = await getMessagesWithVisualMediaAttachments(conversationId, {
|
||||
limit: Constants.CONVERSATION.DEFAULT_MEDIA_FETCH_COUNT,
|
||||
});
|
||||
const rawDocuments = await getMessagesWithFileAttachments(conversationId, {
|
||||
limit: Constants.CONVERSATION.DEFAULT_DOCUMENTS_FETCH_COUNT,
|
||||
});
|
||||
const rawMedia = await getMessagesWithVisualMediaAttachments(
|
||||
conversationId,
|
||||
Constants.CONVERSATION.DEFAULT_MEDIA_FETCH_COUNT
|
||||
);
|
||||
const rawDocuments = await getMessagesWithFileAttachments(
|
||||
conversationId,
|
||||
Constants.CONVERSATION.DEFAULT_DOCUMENTS_FETCH_COUNT
|
||||
);
|
||||
|
||||
const media = _.flatten(
|
||||
rawMedia.map(attributes => {
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
} from '../models/conversation';
|
||||
import { MessageCollection, MessageModel } from '../models/message';
|
||||
import { MessageAttributes, MessageDirection } from '../models/messageType';
|
||||
import { StorageItem } from '../node/storage_item';
|
||||
import { HexKeyPair } from '../receiver/keypairs';
|
||||
import { getConversationController } from '../session/conversations';
|
||||
import { getSodium } from '../session/crypto';
|
||||
|
@ -37,12 +38,6 @@ let _shuttingDown = false;
|
|||
let _shutdownCallback: any = null;
|
||||
let _shutdownPromise: any = null;
|
||||
|
||||
export type StorageItem = {
|
||||
id: string;
|
||||
value: any;
|
||||
timestamp?: number;
|
||||
};
|
||||
|
||||
export type IdentityKey = {
|
||||
id: string;
|
||||
publicKey: ArrayBuffer;
|
||||
|
@ -613,9 +608,11 @@ export async function searchMessagesInConversation(
|
|||
conversationId: string,
|
||||
limit: number
|
||||
): Promise<Array<MessageAttributes>> {
|
||||
const messages = (await channels.searchMessagesInConversation(query, conversationId, {
|
||||
limit,
|
||||
})) as Array<MessageAttributes>;
|
||||
const messages = (await channels.searchMessagesInConversation(
|
||||
query,
|
||||
conversationId,
|
||||
limit
|
||||
)) as Array<MessageAttributes>;
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
@ -1030,20 +1027,16 @@ async function callChannel(name: string): Promise<any> {
|
|||
|
||||
export async function getMessagesWithVisualMediaAttachments(
|
||||
conversationId: string,
|
||||
options?: { limit: number }
|
||||
limit?: number
|
||||
): Promise<Array<MessageAttributes>> {
|
||||
return channels.getMessagesWithVisualMediaAttachments(conversationId, {
|
||||
limit: options?.limit,
|
||||
});
|
||||
return channels.getMessagesWithVisualMediaAttachments(conversationId, limit);
|
||||
}
|
||||
|
||||
export async function getMessagesWithFileAttachments(
|
||||
conversationId: string,
|
||||
options?: { limit: number }
|
||||
limit: number
|
||||
): Promise<Array<MessageAttributes>> {
|
||||
return channels.getMessagesWithFileAttachments(conversationId, {
|
||||
limit: options?.limit,
|
||||
});
|
||||
return channels.getMessagesWithFileAttachments(conversationId, limit);
|
||||
}
|
||||
|
||||
export const SNODE_POOL_ITEM_ID = 'SNODE_POOL_ITEM_ID';
|
||||
|
|
|
@ -34,6 +34,6 @@ console.log(`userData: ${app.getPath('userData')}`);
|
|||
const userDataPath = app.getPath('userData');
|
||||
const targetPath = path.join(userDataPath, 'config.json');
|
||||
|
||||
const userConfig = start('user', targetPath);
|
||||
export const userConfig = start('user', targetPath);
|
||||
|
||||
export type UserConfig = typeof userConfig;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,20 +1,15 @@
|
|||
const electron = require('electron');
|
||||
const sql = require('./sql');
|
||||
const { remove: removeUserConfig } = require('./user_config');
|
||||
const { remove: removeEphemeralConfig } = require('./ephemeral_config');
|
||||
|
||||
const { ipcMain } = electron;
|
||||
|
||||
module.exports = {
|
||||
initialize,
|
||||
};
|
||||
import { ipcMain } from 'electron';
|
||||
import sql from './sql';
|
||||
import { userConfig } from './config/user_config';
|
||||
import { ephemeralConfig } from './config/ephemeral_config';
|
||||
|
||||
let initialized = false;
|
||||
|
||||
const SQL_CHANNEL_KEY = 'sql-channel';
|
||||
const ERASE_SQL_KEY = 'erase-sql-key';
|
||||
// tslint:disable: no-console
|
||||
|
||||
function initialize() {
|
||||
export function initialize() {
|
||||
if (initialized) {
|
||||
throw new Error('sqlChannels: already initialized!');
|
||||
}
|
||||
|
@ -38,8 +33,8 @@ function initialize() {
|
|||
|
||||
ipcMain.on(ERASE_SQL_KEY, event => {
|
||||
try {
|
||||
removeUserConfig();
|
||||
removeEphemeralConfig();
|
||||
userConfig.remove();
|
||||
ephemeralConfig.remove();
|
||||
event.sender.send(`${ERASE_SQL_KEY}-done`);
|
||||
} catch (error) {
|
||||
const errorForDisplay = error && error.stack ? error.stack : error;
|
5
ts/node/storage_item.ts
Normal file
5
ts/node/storage_item.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export type StorageItem = {
|
||||
id: string;
|
||||
value: any;
|
||||
timestamp?: number;
|
||||
};
|
Loading…
Reference in a new issue