Skip to content

Commit

Permalink
#2621 potential fix (#2833)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eonasdan authored Jul 3, 2023
1 parent 381dee0 commit a1e1dec
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup
uses: ./.github/workflows/base
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion build/change-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const DRY_RUN =

// These are the filetypes we only care about replacing the version
const GLOB = [
'**/*.{css,html,js,json,md,scss,txt,yml,ts,nuspec}',
'**/*.{css,html,js,json,md,scss,txt,yml,ts,nuspec,properties}',
'!**/change-log*',
];
const GLOBBY_OPTIONS = {
Expand Down
28 changes: 26 additions & 2 deletions dist/js/tempus-dominus.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions dist/js/tempus-dominus.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
sonar.organization=eonasdan
sonar.projectKey=Eonasdan_tempus-dominus

sonar.projectName=tempus-dominus
sonar.projectVersion=6.7.7

sonar.sources = src/
sonar.tests = test/
27 changes: 26 additions & 1 deletion src/js/display/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export default class Display {
*/
_update(unit: ViewUpdateValues): void {
if (!this.widget) return;
//todo do I want some kind of error catching or other guards here?
switch (unit) {
case Unit.seconds:
this.secondDisplay._update(this.widget, this.paint);
Expand All @@ -111,6 +110,9 @@ export default class Display {
case Unit.year:
this.yearDisplay._update(this.widget, this.paint);
break;
case 'decade':
this.decadeDisplay._update(this.widget, this.paint);
break;
case 'clock':
if (!this._hasTime) break;
this.timeDisplay._update(this.widget);
Expand Down Expand Up @@ -814,6 +816,29 @@ export default class Display {
this._dispose();
if (wasVisible) this.show();
}

refreshCurrentView() {
//if the widget is not showing, just destroy it
if (!this._isVisible) this._dispose();

switch (this.optionsStore.currentView) {
case 'clock':
this._update('clock');
break;
case 'calendar':
this._update(Unit.date);
break;
case 'months':
this._update(Unit.month);
break;
case 'years':
this._update(Unit.year);
break;
case 'decades':
this._update('decade');
break;
}
}
}

export type Paint = (
Expand Down
2 changes: 1 addition & 1 deletion src/js/tempus-dominus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TempusDominus {
this.optionsStore.viewDate.setLocalization(
this.optionsStore.options.localization
);
this.display._rebuild();
this.display.refreshCurrentView();
}

// noinspection JSUnusedGlobalSymbols
Expand Down
2 changes: 1 addition & 1 deletion src/js/utilities/event-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DateTime, Unit } from '../datetime';
import ActionTypes from './action-types';
import { BaseEvent } from './event-types';

export type ViewUpdateValues = Unit | 'clock' | 'calendar' | 'all';
export type ViewUpdateValues = Unit | 'decade' | 'clock' | 'calendar' | 'all';

class EventEmitter<T> {
private subscribers: ((value?: T) => void)[] = [];
Expand Down
1 change: 1 addition & 0 deletions types/display/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export default class Display {
* @private
*/
_rebuild(): void;
refreshCurrentView(): void;
}
export type Paint = (
unit: Unit | 'decade',
Expand Down
2 changes: 1 addition & 1 deletion types/utilities/event-emitter.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DateTime, Unit } from '../datetime';
import ActionTypes from './action-types';
import { BaseEvent } from './event-types';
export type ViewUpdateValues = Unit | 'clock' | 'calendar' | 'all';
export type ViewUpdateValues = Unit | 'decade' | 'clock' | 'calendar' | 'all';
declare class EventEmitter<T> {
private subscribers;
subscribe(callback: (value: T) => void): any;
Expand Down

0 comments on commit a1e1dec

Please sign in to comment.