Skip to content

addSnapshotListener triggers twice when setting timestamp field with FieldValue.serverTimestamp() #442

@mourjan

Description

@mourjan

Step 2: Describe your environment

  • Android device: _samsung J7 & emulator
  • Android OS version: 23 & 26_
  • Google Play Services version: 11.9.75_
  • Firebase/Play Services SDK version: 11.8.0___

Step 3: Describe the problem:

the scenario goe like this:

I have a recyclerView setup with a firestore adapter setup along with a query fetching documents like CHAT/MESSAGES (for example). all is normal.

now whenever I choose to insert a new message or update it, I set {stamp: FieldValue.serverTimestamp()| on a new docRef or update {stamp:FieldValue.serverTimestamp()} on a docRef.
both of setting and updating cause the addSnapshotListener to trigger twice.
first time, the message object (snapshot) will return with stamp field set to null,
and the second time with stamp field set with the correct server timestamp value.

I also assure you, that my addSnapshotListener is well implemented and there is only one listener running.. no more.

Expected Results:

I should not get an update from snapshot listener if the document's stamp field <FieldValue.serverTimestamp()> is null

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions