Skip to content

Remove Platform.useProto3Json flag #2866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/firestore/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { Document, MaybeDocument, NoDocument } from '../model/document';
import { DocumentKey } from '../model/document_key';
import { DeleteMutation, Mutation, Precondition } from '../model/mutation';
import { FieldPath, ResourcePath } from '../model/path';
import { JsonProtoSerializer } from '../remote/serializer';
import { isServerTimestamp } from '../model/server_timestamps';
import { refValue } from '../model/values';
import { PlatformSupport } from '../platform/platform';
Expand Down Expand Up @@ -544,9 +543,7 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService {
return value;
}
};
const serializer = new JsonProtoSerializer(databaseId, {
useProto3Json: PlatformSupport.getPlatform().useProto3Json
});
const serializer = PlatformSupport.getPlatform().newSerializer(databaseId);
return new UserDataReader(serializer, preConverter);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/firestore/src/local/indexeddb_persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1328,9 +1328,9 @@ export class IndexedDbPersistenceProvider implements PersistenceProvider {
);

// Opt to use proto3 JSON in case the platform doesn't support Uint8Array.
const serializer = new JsonProtoSerializer(databaseInfo.databaseId, {
useProto3Json: PlatformSupport.getPlatform().useProto3Json
});
const serializer = PlatformSupport.getPlatform().newSerializer(
databaseInfo.databaseId
);

if (!WebStorageSharedClientState.isAvailable(platform)) {
throw new FirestoreError(
Expand Down
6 changes: 0 additions & 6 deletions packages/firestore/src/platform/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ export interface Platform {

/** True if and only if the Base64 conversion functions are available. */
readonly base64Available: boolean;

/**
* True if timestamps, bytes and numbers are represented in Proto3 JSON
* format (in-memory and on the wire)
*/
readonly useProto3Json: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { WebChannelConnection } from './webchannel_connection';
const crypto = window.crypto || (window as any).msCrypto;

export class BrowserPlatform implements Platform {
readonly useProto3Json = true;
readonly base64Available: boolean;

constructor() {
Expand Down
1 change: 0 additions & 1 deletion packages/firestore/src/platform_node/node_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { GrpcConnection } from './grpc_connection';
import { loadProtos } from './load_protos';

export class NodePlatform implements Platform {
readonly useProto3Json = false;
readonly base64Available = true;

readonly document = null;
Expand Down
6 changes: 4 additions & 2 deletions packages/firestore/test/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ export function testUserDataWriter(): UserDataWriter {
}

export function testUserDataReader(useProto3Json?: boolean): UserDataReader {
useProto3Json = useProto3Json ?? PlatformSupport.getPlatform().useProto3Json;
const databaseId = new DatabaseId('test-project');
return new UserDataReader(
new JsonProtoSerializer(new DatabaseId('test-project'), { useProto3Json }),
useProto3Json !== undefined
? new JsonProtoSerializer(databaseId, { useProto3Json })
: PlatformSupport.getPlatform().newSerializer(databaseId),
preConverter
);
}
Expand Down
4 changes: 0 additions & 4 deletions packages/firestore/test/util/test_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ export class TestPlatform implements Platform {
this.mockWindow = new FakeWindow(this.mockStorage);
}

get useProto3Json(): boolean {
return this.basePlatform.useProto3Json;
}

get document(): Document | null {
// FakeWindow doesn't support full Document interface.
return this.mockDocument as any; // eslint-disable-line @typescript-eslint/no-explicit-any
Expand Down