Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Sep 29, 2019
1 parent 7299ea3 commit 972524a
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages-premium
4 changes: 4 additions & 0 deletions packages/core/src/CalendarComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ export default class CalendarComponent extends Component<CalendarComponentProps>
updateSize(isResize = false) {
let { view } = this

if (!view) {
return // why?
}

if (isResize) {
view.addScroll(view.queryScroll())
}
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/OptionsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export default class OptionsManager {


mutate(updates, removals: string[], isDynamic?: boolean) {

if (!Object.keys(updates).length && !removals.length) {
return
}

let overrideHash = isDynamic ? this.dynamicOverrides : this.overrides

__assign(overrideHash, updates)
Expand Down
28 changes: 15 additions & 13 deletions packages/core/src/View.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default abstract class View extends DateComponent<ViewProps> {


render(props: ViewProps, context: ComponentContext) {
this.renderDatesMem(props.dateProfile, props.dateProfileGenerator)
this.renderDatesMem(props.dateProfile)
this.renderBusinessHoursMem(props.businessHours)
this.renderDateSelectionMem(props.dateSelection)
this.renderEventsMem(props.eventStore)
Expand Down Expand Up @@ -148,12 +148,11 @@ export default abstract class View extends DateComponent<ViewProps> {
// Date Rendering
// -----------------------------------------------------------------------------------------------------------------

renderDatesWrap(dateProfile: DateProfile, dateProfileGenerator: DateProfileGenerator) {
renderDatesWrap(dateProfile: DateProfile) {
this.renderDates(dateProfile)
this.addScroll({
duration: createDuration(this.context.options.scrollTime)
})
this.startNowIndicator(dateProfile, dateProfileGenerator) // shouldn't render yet because updateSize will be called soon
}

unrenderDatesWrap() {
Expand Down Expand Up @@ -274,14 +273,16 @@ export default abstract class View extends DateComponent<ViewProps> {
// Immediately render the current time indicator and begins re-rendering it at an interval,
// which is defined by this.getNowIndicatorUnit().
// TODO: somehow do this for the current whole day's background too
// USAGE: must be called manually from subclasses' render methods! don't need to call stopNowIndicator tho
startNowIndicator(dateProfile: DateProfile, dateProfileGenerator: DateProfileGenerator) {
let { calendar, dateEnv, options } = this.context
let unit
let update
let delay // ms wait value

if (options.nowIndicator) {
if (options.nowIndicator && !this.initialNowDate) {
unit = this.getNowIndicatorUnit(dateProfile, dateProfileGenerator)

if (unit) {
update = this.updateNowIndicator.bind(this)

Expand Down Expand Up @@ -333,17 +334,18 @@ export default abstract class View extends DateComponent<ViewProps> {
// Immediately unrenders the view's current time indicator and stops any re-rendering timers.
// Won't cause side effects if indicator isn't rendered.
stopNowIndicator() {
if (this.isNowIndicatorRendered) {

if (this.nowIndicatorTimeoutID) {
clearTimeout(this.nowIndicatorTimeoutID)
this.nowIndicatorTimeoutID = null
}
if (this.nowIndicatorIntervalID) {
clearInterval(this.nowIndicatorIntervalID)
this.nowIndicatorIntervalID = null
}
if (this.nowIndicatorTimeoutID) {
clearTimeout(this.nowIndicatorTimeoutID)
this.nowIndicatorTimeoutID = null
}

if (this.nowIndicatorIntervalID) {
clearInterval(this.nowIndicatorIntervalID)
this.nowIndicatorIntervalID = null
}

if (this.isNowIndicatorRendered) {
this.unrenderNowIndicator()
this.isNowIndicatorRendered = false
}
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/common/slicing-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EventInteractionState } from '../interactions/event-interaction-state'
import { Duration } from '../datelib/duration'
import { memoize } from '../util/memoize'
import { DateMarker, addMs } from '../datelib/marker'
import Calendar from '../Calendar'

export interface SliceableProps {
dateSelection: DateSpan
Expand Down Expand Up @@ -44,6 +45,7 @@ export default abstract class Slicer<SegType extends Seg, ExtraArgs extends any[
props: SliceableProps,
dateProfile: DateProfile,
nextDayThreshold: Duration | null,
calendar: Calendar,
component: DateComponent<any>, // TODO: kill
...extraArgs: ExtraArgs
): SlicedProps<SegType> {
Expand All @@ -52,7 +54,7 @@ export default abstract class Slicer<SegType extends Seg, ExtraArgs extends any[

return {
dateSelectionSegs: this.sliceDateSelection(props.dateSelection, eventUiBases, component, ...extraArgs),
businessHourSegs: this.sliceBusinessHours(props.businessHours, dateProfile, nextDayThreshold, component, ...extraArgs),
businessHourSegs: this.sliceBusinessHours(props.businessHours, dateProfile, nextDayThreshold, calendar, component, ...extraArgs),
fgEventSegs: eventSegs.fg,
bgEventSegs: eventSegs.bg,
eventDrag: this.sliceEventDrag(props.eventDrag, eventUiBases, dateProfile, nextDayThreshold, component, ...extraArgs),
Expand All @@ -78,6 +80,7 @@ export default abstract class Slicer<SegType extends Seg, ExtraArgs extends any[
businessHours: EventStore,
dateProfile: DateProfile,
nextDayThreshold: Duration | null,
calendar: Calendar,
component: DateComponent<any>, // TODO: kill
...extraArgs: ExtraArgs
): SegType[] {
Expand All @@ -89,7 +92,7 @@ export default abstract class Slicer<SegType extends Seg, ExtraArgs extends any[
expandRecurring(
businessHours,
computeActiveRange(dateProfile, Boolean(nextDayThreshold)),
component.context.calendar
calendar
),
{},
dateProfile,
Expand Down
2 changes: 2 additions & 0 deletions packages/daygrid/src/AbstractDayGridView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export default abstract class AbstractDayGridView extends View {


render(props: ViewProps, context: ComponentContext) {
super.render(props, context)

this.processOptions(context.options)
this.renderSkeleton(context)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/daygrid/src/SimpleDayGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class SimpleDayGrid extends DateComponent<SimpleDayGridProps> {
let { dateProfile, dayTable } = props

dayGrid.receiveProps({
...this.slicer.sliceProps(props, dateProfile, props.nextDayThreshold, dayGrid, dayTable),
...this.slicer.sliceProps(props, dateProfile, props.nextDayThreshold, context.calendar, dayGrid, dayTable),
dateProfile,
cells: dayTable.cells,
isRigid: props.isRigid
Expand Down
2 changes: 2 additions & 0 deletions packages/list/src/ListView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export default class ListView extends View {


render(props: ViewProps, context: ComponentContext) {
super.render(props, context)

let { dayDates, dayRanges } = this.computeDateVars(props.dateProfile)
this.dayDates = dayDates

Expand Down
2 changes: 2 additions & 0 deletions packages/timegrid/src/AbstractTimeGridView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export default abstract class AbstractTimeGridView extends View {


render(props: ViewProps, context: ComponentContext) {
super.render(props, context)

this.renderSkeleton(context)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/timegrid/src/SimpleTimeGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class SimpleTimeGrid extends DateComponent<SimpleTimeGridProps> {
let dayRanges = this.dayRanges = this.buildDayRanges(dayTable, dateProfile, dateEnv)

this.timeGrid.receiveProps({
...this.slicer.sliceProps(props, dateProfile, null, this.timeGrid, dayRanges),
...this.slicer.sliceProps(props, dateProfile, null, context.calendar, this.timeGrid, dayRanges),
dateProfile,
cells: dayTable.cells[0]
}, context)
Expand Down
2 changes: 2 additions & 0 deletions packages/timegrid/src/TimeGridView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export default class TimeGridView extends AbstractTimeGridView {
isRigid: false
}, context)
}

this.startNowIndicator(dateProfile, dateProfileGenerator)
}


Expand Down

0 comments on commit 972524a

Please sign in to comment.