Force social graph to pull down updates after beta.11 install
This commit is contained in:
parent
d07b8e82b2
commit
bab59ba2a1
13 changed files with 90 additions and 28 deletions
|
@ -539,6 +539,13 @@
|
|||
window.Events.setThemeSetting(newThemeSetting);
|
||||
}
|
||||
|
||||
if (
|
||||
window.isBeforeVersion(lastVersion, 'v1.35.0-beta.11') &&
|
||||
window.isAfterVersion(lastVersion, 'v1.35.0-beta.1')
|
||||
) {
|
||||
await window.Signal.Util.eraseAllStorageServiceState();
|
||||
}
|
||||
|
||||
// This one should always be last - it could restart the app
|
||||
if (window.isBeforeVersion(lastVersion, 'v1.15.0-beta.5')) {
|
||||
await window.Signal.Logs.deleteAll();
|
||||
|
|
|
@ -614,8 +614,9 @@
|
|||
if (response === this.messageRequestEnum.ACCEPT) {
|
||||
this.unblock();
|
||||
this.enableProfileSharing();
|
||||
this.sendProfileKeyUpdate();
|
||||
|
||||
if (!fromSync) {
|
||||
this.sendProfileKeyUpdate();
|
||||
// Locally accepted
|
||||
await this.handleReadAndDownloadAttachments();
|
||||
}
|
||||
|
@ -945,14 +946,14 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
const fromContact = this.getIsAddedByContact();
|
||||
const isFromOrAddedByTrustedContact = this.isFromOrAddedByTrustedContact();
|
||||
const hasSentMessages = this.getSentMessageCount() > 0;
|
||||
const hasMessagesBeforeMessageRequests =
|
||||
(this.get('messageCountBeforeMessageRequests') || 0) > 0;
|
||||
const hasNoMessages = (this.get('messageCount') || 0) === 0;
|
||||
|
||||
return (
|
||||
fromContact ||
|
||||
isFromOrAddedByTrustedContact ||
|
||||
hasSentMessages ||
|
||||
hasMessagesBeforeMessageRequests ||
|
||||
// an empty conversation is the scenario where we need to rely on
|
||||
|
@ -1183,10 +1184,17 @@
|
|||
return [this.getSendTarget()];
|
||||
}
|
||||
const me = ConversationController.getOurConversationId();
|
||||
return _.without(this.get('members'), me).map(memberId => {
|
||||
const c = ConversationController.get(memberId);
|
||||
return c.getSendTarget();
|
||||
});
|
||||
|
||||
// The list of members might not always be conversationIds for old groups.
|
||||
return _.compact(
|
||||
this.get('members').map(memberId => {
|
||||
const c = ConversationController.get(memberId);
|
||||
if (c.id === me) {
|
||||
return null;
|
||||
}
|
||||
return c.getSendTarget();
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
async getQuoteAttachment(attachments, preview, sticker) {
|
||||
|
@ -1793,17 +1801,12 @@
|
|||
};
|
||||
},
|
||||
|
||||
getIsContact() {
|
||||
// Is this someone who is a contact, or are we sharing our profile with them?
|
||||
// Or is the person who added us to this group a contact or are we sharing profile
|
||||
// with them?
|
||||
isFromOrAddedByTrustedContact() {
|
||||
if (this.isPrivate()) {
|
||||
return Boolean(this.get('name'));
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
getIsAddedByContact() {
|
||||
if (this.isPrivate()) {
|
||||
return this.getIsContact();
|
||||
return Boolean(this.get('name')) || this.get('profileSharing');
|
||||
}
|
||||
|
||||
const addedBy = this.get('addedBy');
|
||||
|
@ -1816,7 +1819,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
return conv.getIsContact();
|
||||
return Boolean(conv.get('name')) || conv.get('profileSharing');
|
||||
},
|
||||
|
||||
async updateLastMessage() {
|
||||
|
|
11
preload.js
11
preload.js
|
@ -63,6 +63,17 @@ try {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
window.isAfterVersion = (toCheck, baseVersion) => {
|
||||
try {
|
||||
return semver.gt(toCheck, baseVersion);
|
||||
} catch (error) {
|
||||
window.log.error(
|
||||
`isBeforeVersion error: toCheck: ${toCheck}, baseVersion: ${baseVersion}`,
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
const ipc = electron.ipcRenderer;
|
||||
const localeMessages = ipc.sendSync('locale-data');
|
||||
|
|
|
@ -2,6 +2,6 @@ export function put(key: string, value: any) {
|
|||
window.storage.put(key, value);
|
||||
}
|
||||
|
||||
export function remove(key: string) {
|
||||
window.storage.remove(key);
|
||||
export async function remove(key: string) {
|
||||
await window.storage.remove(key);
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ const dataInterface: ClientInterface = {
|
|||
updateConversations,
|
||||
removeConversation,
|
||||
|
||||
eraseStorageIdFromConversations,
|
||||
getAllConversations,
|
||||
getAllConversationIds,
|
||||
getAllPrivateConversations,
|
||||
|
@ -770,6 +771,10 @@ async function _removeConversations(ids: Array<string>) {
|
|||
await channels.removeConversation(ids);
|
||||
}
|
||||
|
||||
async function eraseStorageIdFromConversations() {
|
||||
await channels.eraseStorageIdFromConversations();
|
||||
}
|
||||
|
||||
async function getAllConversations({
|
||||
ConversationCollection,
|
||||
}: {
|
||||
|
|
|
@ -67,6 +67,7 @@ export interface DataInterface {
|
|||
removeAllSessions: () => Promise<void>;
|
||||
getAllSessions: () => Promise<Array<SessionType>>;
|
||||
|
||||
eraseStorageIdFromConversations: () => Promise<void>;
|
||||
getConversationCount: () => Promise<number>;
|
||||
saveConversation: (data: ConversationType) => Promise<void>;
|
||||
saveConversations: (array: Array<ConversationType>) => Promise<void>;
|
||||
|
|
|
@ -104,6 +104,7 @@ const dataInterface: ServerInterface = {
|
|||
updateConversation,
|
||||
updateConversations,
|
||||
removeConversation,
|
||||
eraseStorageIdFromConversations,
|
||||
getAllConversations,
|
||||
getAllConversationIds,
|
||||
getAllPrivateConversations,
|
||||
|
@ -2240,6 +2241,16 @@ async function getConversationById(id: string) {
|
|||
return jsonToObject(row.json);
|
||||
}
|
||||
|
||||
async function eraseStorageIdFromConversations() {
|
||||
const db = getInstance();
|
||||
|
||||
await db.run(
|
||||
`UPDATE conversations SET
|
||||
json = json_remove(json, '$.storageID');
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
async function getAllConversations() {
|
||||
const db = getInstance();
|
||||
const rows = await db.all('SELECT json FROM conversations ORDER BY id ASC;');
|
||||
|
|
|
@ -80,6 +80,7 @@ function putItemExternal(key: string, value: any): ItemPutExternalAction {
|
|||
}
|
||||
|
||||
function removeItem(key: string): ItemRemoveAction {
|
||||
// tslint:disable-next-line no-floating-promises
|
||||
storageShim.remove(key);
|
||||
|
||||
return {
|
||||
|
|
|
@ -15,7 +15,10 @@ import { isFileDangerous } from './isFileDangerous';
|
|||
import { makeLookup } from './makeLookup';
|
||||
import { migrateColor } from './migrateColor';
|
||||
import { missingCaseError } from './missingCaseError';
|
||||
import { runStorageServiceSyncJob } from './storageService';
|
||||
import {
|
||||
eraseAllStorageServiceState,
|
||||
runStorageServiceSyncJob,
|
||||
} from './storageService';
|
||||
import * as zkgroup from './zkgroup';
|
||||
|
||||
export {
|
||||
|
@ -25,6 +28,7 @@ export {
|
|||
createWaitBatcher,
|
||||
deleteForEveryone,
|
||||
downloadAttachment,
|
||||
eraseAllStorageServiceState,
|
||||
generateSecurityNumber,
|
||||
getSafetyNumberPlaceholder,
|
||||
GoogleChrome,
|
||||
|
|
|
@ -207,7 +207,7 @@
|
|||
"rule": "jQuery-wrap(",
|
||||
"path": "js/models/conversations.js",
|
||||
"line": " await wrap(",
|
||||
"lineNumber": 663,
|
||||
"lineNumber": 664,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2020-06-09T20:26:46.515Z"
|
||||
},
|
||||
|
|
|
@ -8,8 +8,8 @@ export function markDone() {
|
|||
window.storage.put('chromiumRegistrationDone', '');
|
||||
}
|
||||
|
||||
export function remove() {
|
||||
window.storage.remove('chromiumRegistrationDone');
|
||||
export async function remove() {
|
||||
await window.storage.remove('chromiumRegistrationDone');
|
||||
}
|
||||
|
||||
export function isDone() {
|
||||
|
|
|
@ -10,6 +10,8 @@ import {
|
|||
deriveStorageItemKey,
|
||||
deriveStorageManifestKey,
|
||||
} from '../Crypto';
|
||||
import dataInterface from '../sql/Client';
|
||||
const { eraseStorageIdFromConversations, updateConversation } = dataInterface;
|
||||
import {
|
||||
AccountRecordClass,
|
||||
ContactRecordClass,
|
||||
|
@ -143,7 +145,7 @@ async function mergeGroupV1Record(
|
|||
|
||||
applyMessageRequestState(groupV1Record, conversation);
|
||||
|
||||
window.Signal.Data.updateConversation(conversation.attributes);
|
||||
updateConversation(conversation.attributes);
|
||||
|
||||
window.log.info(`storageService.mergeGroupV1Record: merged ${storageID}`);
|
||||
}
|
||||
|
@ -223,7 +225,7 @@ async function mergeContactRecord(
|
|||
);
|
||||
}
|
||||
|
||||
window.Signal.Data.updateConversation(conversation.attributes);
|
||||
updateConversation(conversation.attributes);
|
||||
|
||||
window.log.info(`storageService.mergeContactRecord: merged ${storageID}`);
|
||||
}
|
||||
|
@ -284,7 +286,7 @@ async function mergeAccountRecord(
|
|||
storageID,
|
||||
});
|
||||
|
||||
window.Signal.Data.updateConversation(conversation.attributes);
|
||||
updateConversation(conversation.attributes);
|
||||
|
||||
window.log.info(
|
||||
`storageService.mergeAccountRecord: merged profile ${storageID}`
|
||||
|
@ -411,6 +413,12 @@ async function processManifest(
|
|||
}
|
||||
|
||||
export async function runStorageServiceSyncJob() {
|
||||
if (!window.storage.get('storageKey')) {
|
||||
throw new Error('runStorageServiceSyncJob: Cannot start; no storage key!');
|
||||
}
|
||||
|
||||
window.log.info('runStorageServiceSyncJob: starting...');
|
||||
|
||||
const localManifestVersion = window.storage.get('manifestVersion') || 0;
|
||||
|
||||
let manifest;
|
||||
|
@ -419,6 +427,7 @@ export async function runStorageServiceSyncJob() {
|
|||
|
||||
// Guarding against no manifests being returned, everything should be ok
|
||||
if (!manifest) {
|
||||
window.log.info('runStorageServiceSyncJob: no manifest, returning early');
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -442,4 +451,14 @@ export async function runStorageServiceSyncJob() {
|
|||
if (shouldUpdateVersion) {
|
||||
window.storage.put('manifestVersion', version);
|
||||
}
|
||||
window.log.info('runStorageServiceSyncJob: complete');
|
||||
}
|
||||
|
||||
// Note: this function is meant to be called before ConversationController is hydrated.
|
||||
// It goes directly to the database, so in-memory conversations will be out of date.
|
||||
export async function eraseAllStorageServiceState() {
|
||||
window.log.info('eraseAllStorageServiceState: starting...');
|
||||
await window.storage.remove('manifestVersion');
|
||||
await eraseStorageIdFromConversations();
|
||||
window.log.info('eraseAllStorageServiceState: complete');
|
||||
}
|
||||
|
|
2
ts/window.d.ts
vendored
2
ts/window.d.ts
vendored
|
@ -62,7 +62,7 @@ declare global {
|
|||
setBadgeCount: (count: number) => void;
|
||||
storage: {
|
||||
put: (key: string, value: any) => void;
|
||||
remove: (key: string) => void;
|
||||
remove: (key: string) => Promise<void>;
|
||||
get: <T = any>(key: string) => T | undefined;
|
||||
addBlockedNumber: (number: string) => void;
|
||||
isBlocked: (number: string) => boolean;
|
||||
|
|
Loading…
Add table
Reference in a new issue