mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
preparing mobile app for unsealed channel data
This commit is contained in:
parent
011a439870
commit
7559c39bca
@ -669,7 +669,7 @@ SPEC CHECKSUMS:
|
|||||||
FirebaseInstallations: 99d24bac0243cf8b0e96cf5426340d211f0bcc80
|
FirebaseInstallations: 99d24bac0243cf8b0e96cf5426340d211f0bcc80
|
||||||
FirebaseMessaging: 4487bbff9b9b927ba1dd3ea40d1ceb58e4ee3cb5
|
FirebaseMessaging: 4487bbff9b9b927ba1dd3ea40d1ceb58e4ee3cb5
|
||||||
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
|
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
|
||||||
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
|
glog: 3d02b25ca00c2d456734d0bcff864cbc62f6ae1a
|
||||||
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
|
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
|
||||||
GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7
|
GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7
|
||||||
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
|
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
|
||||||
|
@ -5,7 +5,7 @@ export async function getChannels(server, token, revision) {
|
|||||||
if (revision != null) {
|
if (revision != null) {
|
||||||
param += `&channelRevision=${revision}`
|
param += `&channelRevision=${revision}`
|
||||||
}
|
}
|
||||||
param += `&types=${encodeURIComponent(JSON.stringify(['superbasic']))}`;
|
param += `&types=${encodeURIComponent(JSON.stringify(['sealed','superbasic']))}`;
|
||||||
let channels = await fetchWithTimeout(`https://${server}/content/channels${param}`, { method: 'GET' });
|
let channels = await fetchWithTimeout(`https://${server}/content/channels${param}`, { method: 'GET' });
|
||||||
checkResponse(channels)
|
checkResponse(channels)
|
||||||
let ret = await channels.json()
|
let ret = await channels.json()
|
||||||
|
@ -8,7 +8,7 @@ export async function getContactChannels(server, token, viewRevision, channelRev
|
|||||||
if (channelRevision != null) {
|
if (channelRevision != null) {
|
||||||
param += `&channelRevision=${channelRevision}`;
|
param += `&channelRevision=${channelRevision}`;
|
||||||
}
|
}
|
||||||
param += `&types=${encodeURIComponent(JSON.stringify(['superbasic']))}`;
|
param += `&types=${encodeURIComponent(JSON.stringify(['sealed','superbasic']))}`;
|
||||||
let channels = await fetchWithTimeout(`https://${server}/content/channels${param}`, { method: 'GET' });
|
let channels = await fetchWithTimeout(`https://${server}/content/channels${param}`, { method: 'GET' });
|
||||||
checkResponse(channels)
|
checkResponse(channels)
|
||||||
return await channels.json()
|
return await channels.json()
|
||||||
|
@ -132,7 +132,9 @@ export function useCardContext() {
|
|||||||
detailRevision: channel?.data?.detailRevision,
|
detailRevision: channel?.data?.detailRevision,
|
||||||
topicRevision: channel?.data?.topicRevision,
|
topicRevision: channel?.data?.topicRevision,
|
||||||
detail: channel?.data?.channelDetail,
|
detail: channel?.data?.channelDetail,
|
||||||
|
unsealed_detail: null,
|
||||||
summary: channel?.data?.channelSummary,
|
summary: channel?.data?.channelSummary,
|
||||||
|
unsealed_summary: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const setCardChannelItem = (cardId, channel) => {
|
const setCardChannelItem = (cardId, channel) => {
|
||||||
@ -148,6 +150,7 @@ export function useCardContext() {
|
|||||||
let channel = card.channels.get(channelId);
|
let channel = card.channels.get(channelId);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel.detail = detail;
|
channel.detail = detail;
|
||||||
|
channel.unsealed_detail = null;
|
||||||
channel.detailRevision = revision;
|
channel.detailRevision = revision;
|
||||||
card.channels.set(channelId, channel);
|
card.channels.set(channelId, channel);
|
||||||
cards.current.set(cardId, card);
|
cards.current.set(cardId, card);
|
||||||
@ -160,6 +163,7 @@ export function useCardContext() {
|
|||||||
let channel = card.channels.get(channelId);
|
let channel = card.channels.get(channelId);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel.summary = summary;
|
channel.summary = summary;
|
||||||
|
channel.unsealed_summary = null;
|
||||||
channel.topicRevision = revision;
|
channel.topicRevision = revision;
|
||||||
card.channels.set(channelId, channel);
|
card.channels.set(channelId, channel);
|
||||||
cards.current.set(cardId, card);
|
cards.current.set(cardId, card);
|
||||||
|
@ -46,7 +46,9 @@ export function useChannelContext() {
|
|||||||
update.channelId = channel?.id;
|
update.channelId = channel?.id;
|
||||||
update.revision = channel?.revision;
|
update.revision = channel?.revision;
|
||||||
update.detail = channel?.data?.channelDetail;
|
update.detail = channel?.data?.channelDetail;
|
||||||
|
update.unsealedDetail = null;
|
||||||
update.summary = channel?.data?.channelSummary;
|
update.summary = channel?.data?.channelSummary;
|
||||||
|
update.unsealedSummary = null;
|
||||||
update.detailRevision = channel?.data?.detailRevision;
|
update.detailRevision = channel?.data?.detailRevision;
|
||||||
update.topicRevision = channel?.data?.topicRevision;
|
update.topicRevision = channel?.data?.topicRevision;
|
||||||
channels.current.set(channelId, update);
|
channels.current.set(channelId, update);
|
||||||
@ -55,6 +57,7 @@ export function useChannelContext() {
|
|||||||
let channel = channels.current.get(channelId);
|
let channel = channels.current.get(channelId);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel.detail = detail;
|
channel.detail = detail;
|
||||||
|
channel.unsealed_detail = null;
|
||||||
channel.detailRevision = revision;
|
channel.detailRevision = revision;
|
||||||
channels.current.set(channelId, channel);
|
channels.current.set(channelId, channel);
|
||||||
}
|
}
|
||||||
@ -63,6 +66,7 @@ export function useChannelContext() {
|
|||||||
let channel = channels.current.get(channelId);
|
let channel = channels.current.get(channelId);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel.summary = summary;
|
channel.summary = summary;
|
||||||
|
channel.unsealed_summary = null;
|
||||||
channel.topicRevision = revision;
|
channel.topicRevision = revision;
|
||||||
channels.current.set(channelId, channel);
|
channels.current.set(channelId, channel);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useState, useRef, useContext } from 'react';
|
import { useEffect, useState, useRef, useContext } from 'react';
|
||||||
import SQLite from "react-native-sqlite-storage";
|
import SQLite from "react-native-sqlite-storage";
|
||||||
|
|
||||||
const DATABAG_DB = 'databag_v048.db';
|
const DATABAG_DB = 'databag_v050.db';
|
||||||
|
|
||||||
export function useStoreContext() {
|
export function useStoreContext() {
|
||||||
const [state, setState] = useState({});
|
const [state, setState] = useState({});
|
||||||
@ -12,11 +12,11 @@ export function useStoreContext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const initSession = async (guid) => {
|
const initSession = async (guid) => {
|
||||||
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS channel_${guid} (channel_id text, revision integer, detail_revision integer, topic_revision integer, blocked integer, sync_revision integer, detail text, summary text, offsync integer, read_revision integer, unique(channel_id))`);
|
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS channel_${guid} (channel_id text, revision integer, detail_revision integer, topic_revision integer, blocked integer, sync_revision integer, detail text, unsealed_detail text, summary text, unsealed_summary text, offsync integer, read_revision integer, unique(channel_id))`);
|
||||||
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS channel_topic_${guid} (channel_id text, topic_id text, revision integer, detail_revision integer, blocked integer, detail text, unique(channel_id, topic_id))`);
|
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS channel_topic_${guid} (channel_id text, topic_id text, revision integer, detail_revision integer, blocked integer, detail text, unsealed_detail text, unique(channel_id, topic_id))`);
|
||||||
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS card_${guid} (card_id text, revision integer, detail_revision integer, profile_revision integer, detail text, profile text, notified_view integer, notified_article integer, notified_profile integer, notified_channel integer, offsync integer, blocked integer, unique(card_id))`);
|
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS card_${guid} (card_id text, revision integer, detail_revision integer, profile_revision integer, detail text, profile text, notified_view integer, notified_article integer, notified_profile integer, notified_channel integer, offsync integer, blocked integer, unique(card_id))`);
|
||||||
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS card_channel_${guid} (card_id text, channel_id text, revision integer, detail_revision integer, topic_revision integer, sync_revision integer, detail text, summary text, offsync integer, blocked integer, read_revision integer, unique(card_id, channel_id))`);
|
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS card_channel_${guid} (card_id text, channel_id text, revision integer, detail_revision integer, topic_revision integer, sync_revision integer, detail text, unsealed_detail text, summary text, unsealed_summary text, offsync integer, blocked integer, read_revision integer, unique(card_id, channel_id))`);
|
||||||
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS card_channel_topic_${guid} (card_id text, channel_id text, topic_id text, revision integer, detail_revision integer, blocked integer, detail text, unique(card_id, channel_id, topic_id))`);
|
await db.current.executeSql(`CREATE TABLE IF NOT EXISTS card_channel_topic_${guid} (card_id text, channel_id text, topic_id text, revision integer, detail_revision integer, blocked integer, detail text, unsealed_detail text, unique(card_id, channel_id, topic_id))`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
@ -198,7 +198,7 @@ export function useStoreContext() {
|
|||||||
},
|
},
|
||||||
setChannelItem: async (guid, channel) => {
|
setChannelItem: async (guid, channel) => {
|
||||||
const { id, revision, data } = channel;
|
const { id, revision, data } = channel;
|
||||||
await db.current.executeSql(`INSERT OR REPLACE INTO channel_${guid} (channel_id, revision, detail_revision, topic_revision, detail, summary) values (?, ?, ?, ?, ?, ?);`, [id, revision, data.detailRevision, data.topicRevision, encodeObject(data.channelDetail), encodeObject(data.channelSummary)]);
|
await db.current.executeSql(`INSERT OR REPLACE INTO channel_${guid} (channel_id, revision, detail_revision, topic_revision, detail, summary, unsealed_detail, unsealed_summary) values (?, ?, ?, ?, ?, ?, null, null);`, [id, revision, data.detailRevision, data.topicRevision, encodeObject(data.channelDetail), encodeObject(data.channelSummary)]);
|
||||||
},
|
},
|
||||||
clearChannelItem: async (guid, channelId) => {
|
clearChannelItem: async (guid, channelId) => {
|
||||||
await db.current.executeSql(`DELETE FROM channel_${guid} WHERE channel_id=?`, [channelId]);
|
await db.current.executeSql(`DELETE FROM channel_${guid} WHERE channel_id=?`, [channelId]);
|
||||||
@ -219,10 +219,10 @@ export function useStoreContext() {
|
|||||||
await db.current.executeSql(`UPDATE channel_${guid} set blocked=? where channel_id=?`, [0, channelId]);
|
await db.current.executeSql(`UPDATE channel_${guid} set blocked=? where channel_id=?`, [0, channelId]);
|
||||||
},
|
},
|
||||||
setChannelItemDetail: async (guid, channelId, revision, detail) => {
|
setChannelItemDetail: async (guid, channelId, revision, detail) => {
|
||||||
await db.current.executeSql(`UPDATE channel_${guid} set detail_revision=?, detail=? where channel_id=?`, [revision, encodeObject(detail), channelId]);
|
await db.current.executeSql(`UPDATE channel_${guid} set detail_revision=?, detail=?, unsealed_detail=null where channel_id=?`, [revision, encodeObject(detail), channelId]);
|
||||||
},
|
},
|
||||||
setChannelItemSummary: async (guid, channelId, revision, summary) => {
|
setChannelItemSummary: async (guid, channelId, revision, summary) => {
|
||||||
await db.current.executeSql(`UPDATE channel_${guid} set topic_revision=?, summary=? where channel_id=?`, [revision, encodeObject(summary), channelId]);
|
await db.current.executeSql(`UPDATE channel_${guid} set topic_revision=?, summary=?, unsealed_summary=null where channel_id=?`, [revision, encodeObject(summary), channelId]);
|
||||||
},
|
},
|
||||||
getChannelItemView: async (guid, channelId) => {
|
getChannelItemView: async (guid, channelId) => {
|
||||||
const values = await getAppValues(db.current, `SELECT revision, detail_revision, topic_revision FROM channel_${guid} WHERE channel_id=?`, [channelId]);
|
const values = await getAppValues(db.current, `SELECT revision, detail_revision, topic_revision FROM channel_${guid} WHERE channel_id=?`, [channelId]);
|
||||||
@ -246,7 +246,9 @@ export function useStoreContext() {
|
|||||||
syncRevision: channel.sync_revision,
|
syncRevision: channel.sync_revision,
|
||||||
blocked: channel.blocked,
|
blocked: channel.blocked,
|
||||||
detail: decodeObject(channel.detail),
|
detail: decodeObject(channel.detail),
|
||||||
|
unsealedDetail: decodeObject(channel.unsealed_detail),
|
||||||
summary: decodeObject(channel.summary),
|
summary: decodeObject(channel.summary),
|
||||||
|
unsealedSummary: decodeObject(channel.unsealed_summary),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -259,11 +261,12 @@ export function useStoreContext() {
|
|||||||
blocked: topic.blocked,
|
blocked: topic.blocked,
|
||||||
detailRevision: topic.detail_revision,
|
detailRevision: topic.detail_revision,
|
||||||
detail: decodeObject(topic.detail),
|
detail: decodeObject(topic.detail),
|
||||||
|
unsealedDetail: decodeObject(topic.unsealed_detail),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
setChannelTopicItem: async (guid, channelId, topic) => {
|
setChannelTopicItem: async (guid, channelId, topic) => {
|
||||||
const { id, revision, data } = topic;
|
const { id, revision, data } = topic;
|
||||||
await db.current.executeSql(`INSERT OR REPLACE INTO channel_topic_${guid} (channel_id, topic_id, revision, detail_revision, detail) values (?, ?, ?, ?, ?);`, [channelId, id, revision, data.detailRevision, encodeObject(data.topicDetail)]);
|
await db.current.executeSql(`INSERT OR REPLACE INTO channel_topic_${guid} (channel_id, topic_id, revision, detail_revision, detail, unsealed_detail) values (?, ?, ?, ?, ?, null);`, [channelId, id, revision, data.detailRevision, encodeObject(data.topicDetail)]);
|
||||||
},
|
},
|
||||||
clearChannelTopicItem: async (guid, channelId, topicId) => {
|
clearChannelTopicItem: async (guid, channelId, topicId) => {
|
||||||
await db.current.executeSql(`DELETE FROM channel_topic_${guid} WHERE channel_id=? and topic_id=?`, [channelId, topicId]);
|
await db.current.executeSql(`DELETE FROM channel_topic_${guid} WHERE channel_id=? and topic_id=?`, [channelId, topicId]);
|
||||||
@ -285,7 +288,7 @@ export function useStoreContext() {
|
|||||||
|
|
||||||
setCardChannelItem: async (guid, cardId, channel) => {
|
setCardChannelItem: async (guid, cardId, channel) => {
|
||||||
const { id, revision, data } = channel;
|
const { id, revision, data } = channel;
|
||||||
await db.current.executeSql(`INSERT OR REPLACE INTO card_channel_${guid} (card_id, channel_id, revision, detail_revision, topic_revision, detail, summary) values (?, ?, ?, ?, ?, ?, ?);`, [cardId, id, revision, data.detailRevision, data.topicRevision, encodeObject(data.channelDetail), encodeObject(data.channelSummary)]);
|
await db.current.executeSql(`INSERT OR REPLACE INTO card_channel_${guid} (card_id, channel_id, revision, detail_revision, topic_revision, detail, summary, unsealed_detail, unsealed_summary) values (?, ?, ?, ?, ?, ?, ?, null, null);`, [cardId, id, revision, data.detailRevision, data.topicRevision, encodeObject(data.channelDetail), encodeObject(data.channelSummary)]);
|
||||||
},
|
},
|
||||||
clearCardChannelItem: async (guid, cardId, channelId) => {
|
clearCardChannelItem: async (guid, cardId, channelId) => {
|
||||||
await db.current.executeSql(`DELETE FROM card_channel_${guid} WHERE card_id=? and channel_id=?`, [cardId, channelId]);
|
await db.current.executeSql(`DELETE FROM card_channel_${guid} WHERE card_id=? and channel_id=?`, [cardId, channelId]);
|
||||||
@ -300,10 +303,10 @@ export function useStoreContext() {
|
|||||||
await db.current.executeSql(`UPDATE card_channel_${guid} set sync_revision=? where card_id=? and channel_id=?`, [revision, cardId, channelId]);
|
await db.current.executeSql(`UPDATE card_channel_${guid} set sync_revision=? where card_id=? and channel_id=?`, [revision, cardId, channelId]);
|
||||||
},
|
},
|
||||||
setCardChannelItemDetail: async (guid, cardId, channelId, revision, detail) => {
|
setCardChannelItemDetail: async (guid, cardId, channelId, revision, detail) => {
|
||||||
await db.current.executeSql(`UPDATE card_channel_${guid} set detail_revision=?, detail=? where card_id=? and channel_id=?`, [revision, encodeObject(detail), cardId, channelId]);
|
await db.current.executeSql(`UPDATE card_channel_${guid} set detail_revision=?, detail=?, unsealed_detail=null where card_id=? and channel_id=?`, [revision, encodeObject(detail), cardId, channelId]);
|
||||||
},
|
},
|
||||||
setCardChannelItemSummary: async (guid, cardId, channelId, revision, summary) => {
|
setCardChannelItemSummary: async (guid, cardId, channelId, revision, summary) => {
|
||||||
await db.current.executeSql(`UPDATE card_channel_${guid} set topic_revision=?, summary=? where card_id=? and channel_id=?`, [revision, encodeObject(summary), cardId, channelId]);
|
await db.current.executeSql(`UPDATE card_channel_${guid} set topic_revision=?, summary=?, unsealed_summary=null where card_id=? and channel_id=?`, [revision, encodeObject(summary), cardId, channelId]);
|
||||||
},
|
},
|
||||||
getCardChannelItemView: async (guid, cardId, channelId) => {
|
getCardChannelItemView: async (guid, cardId, channelId) => {
|
||||||
const values = await getAppValues(db.current, `SELECT revision, detail_revision, topic_revision FROM card_channel_${guid} WHERE card_id=? and channel_id=?`, [cardId, channelId]);
|
const values = await getAppValues(db.current, `SELECT revision, detail_revision, topic_revision FROM card_channel_${guid} WHERE card_id=? and channel_id=?`, [cardId, channelId]);
|
||||||
@ -327,7 +330,9 @@ export function useStoreContext() {
|
|||||||
topicRevision: channel.topic_revision,
|
topicRevision: channel.topic_revision,
|
||||||
syncRevision: channel.sync_revision,
|
syncRevision: channel.sync_revision,
|
||||||
detail: decodeObject(channel.detail),
|
detail: decodeObject(channel.detail),
|
||||||
|
unsealedDetail: decodeObject(channel.unsealed_detail),
|
||||||
summary: decodeObject(channel.summary),
|
summary: decodeObject(channel.summary),
|
||||||
|
unsealedSummary: decodeObject(channel.unsealed_summary),
|
||||||
blocked: channel.blocked,
|
blocked: channel.blocked,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
@ -343,11 +348,12 @@ export function useStoreContext() {
|
|||||||
blocked: topic.blocked,
|
blocked: topic.blocked,
|
||||||
detailRevision: topic.detail_revision,
|
detailRevision: topic.detail_revision,
|
||||||
detail: decodeObject(topic.detail),
|
detail: decodeObject(topic.detail),
|
||||||
|
unsealedDetail: decodeObject(topic.unsealed_detail),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
setCardChannelTopicItem: async (guid, cardId, channelId, topic) => {
|
setCardChannelTopicItem: async (guid, cardId, channelId, topic) => {
|
||||||
const { id, revision, data } = topic;
|
const { id, revision, data } = topic;
|
||||||
await db.current.executeSql(`INSERT OR REPLACE INTO card_channel_topic_${guid} (card_id, channel_id, topic_id, revision, detail_revision, detail) values (?, ?, ?, ?, ?, ?);`, [cardId, channelId, id, revision, data.detailRevision, encodeObject(data.topicDetail)]);
|
await db.current.executeSql(`INSERT OR REPLACE INTO card_channel_topic_${guid} (card_id, channel_id, topic_id, revision, detail_revision, detail, unsealed_detail) values (?, ?, ?, ?, ?, ?, null);`, [cardId, channelId, id, revision, data.detailRevision, encodeObject(data.topicDetail)]);
|
||||||
},
|
},
|
||||||
clearCardChannelTopicItem: async (guid, cardId, channelId, topicId) => {
|
clearCardChannelTopicItem: async (guid, cardId, channelId, topicId) => {
|
||||||
await db.current.executeSql(`DELETE FROM card_channel_topic_${guid} WHERE card_id=? and channel_id=? and topic_id=?`, [cardId, channelId, topicId]);
|
await db.current.executeSql(`DELETE FROM card_channel_topic_${guid} WHERE card_id=? and channel_id=? and topic_id=?`, [cardId, channelId, topicId]);
|
||||||
|
Loading…
Reference in New Issue
Block a user