'Given a list of updates for a user figure out if we need to do a full
resync, or whether we have enough data that we can just apply the delta.'

@defer.inlineCallbacks
def _need_to_do_resync(self, user_id, updates):

    seen_updates = self._seen_updates.get(user_id, set())
    extremity = (yield self.store.get_device_list_last_stream_id_for_remote(user_id))
    stream_id_in_updates = set()
    for (_, stream_id, prev_ids, _) in updates:
        if (not prev_ids):
            defer.returnValue(True)
        for prev_id in prev_ids:
            if (prev_id == extremity):
                continue
            elif (prev_id in seen_updates):
                continue
            elif (prev_id in stream_id_in_updates):
                continue
            else:
                defer.returnValue(True)
        stream_id_in_updates.add(stream_id)
    defer.returnValue(False)
