import Chapters from '../../lib/collections/chapters/collection'
import Sequences, { makeEditableOptions } from '../../lib/collections/sequences/collection'
import { addEditableCallbacks } from '../editor/make_editable_callbacks';
import { getCollectionHooks } from '../mutationCallbacks';

getCollectionHooks("Sequences").newAsync.add(function SequenceNewCreateChapter(sequence) {
  if (sequence._id && !sequence.chaptersDummy) {
    Chapters.insert({sequenceId:sequence._id})
  }
});

addEditableCallbacks({collection: Sequences, options: makeEditableOptions})

import Chapters from '../../lib/collections/chapters/collection'
import Sequences, { makeEditableOptions } from '../../lib/collections/sequences/collection'
import { addEditableCallbacks } from '../editor/make_editable_callbacks';
import { getCollectionHooks } from '../mutationCallbacks';

getCollectionHooks("Sequences").newAsync.add(function SequenceNewCreateChapter(sequence) {
  if (sequence._id) {
    Chapters.insert({sequenceId:sequence._id})
  }
});

addEditableCallbacks({collection: Sequences, options: makeEditableOptions})

Fix type error due to reference to resolver-only field chaptersDummy
Fix type error due to reference to resolver-only field chaptersDummy

This was attempting to check whether a sequence already had a chapter in
it. But it was inside a creation callback, so it never would. Also, it
was checking by looking at the name of a resolver, rather than a field,
so the access would always result in undefined.
