mirror of
https://github.com/shumadrid/obsidian-git-changelog.git
synced 2026-07-22 05:42:16 +00:00
fix: make ReviewChangesReminderInterval notification animate away normally
This commit is contained in:
parent
bf0a1c423f
commit
758e0894f1
2 changed files with 17 additions and 16 deletions
|
|
@ -309,13 +309,16 @@ export class GitChangelogPlugin extends PluginBase<GitChangelogPluginTypes> {
|
|||
})
|
||||
);
|
||||
|
||||
// Every minute it checks if it's a new hour (most common interval) in order to update the potentially outdated interval labels.
|
||||
this.registerInterval(
|
||||
window.setInterval(
|
||||
() => {
|
||||
// Every minute it checks if it's a new hour (most common interval) in order to update the potentially outdated interval labels.
|
||||
const utcCurrentDate = spacetime.now('utc');
|
||||
// Svelte triggers updates only if the strings are different.
|
||||
this.utcCurrentDateHour = formatDateHour(utcCurrentDate);
|
||||
|
||||
// Register minute interval for checkpoint reminders
|
||||
invokeAsyncSafely(() => handleReviewChangesReminderInterval(this));
|
||||
},
|
||||
// eslint-disable-next-line no-magic-numbers
|
||||
60 * 1000
|
||||
|
|
@ -341,14 +344,6 @@ export class GitChangelogPlugin extends PluginBase<GitChangelogPluginTypes> {
|
|||
|
||||
// Also checks the status of the Git plugin
|
||||
this.updateActiveGitFile();
|
||||
|
||||
// Register minute interval for checkpoint reminders
|
||||
this.registerInterval(
|
||||
window.setInterval(() => {
|
||||
invokeAsyncSafely(() => handleReviewChangesReminderInterval(this));
|
||||
// eslint-disable-next-line no-magic-numbers
|
||||
}, 60 * 1000)
|
||||
);
|
||||
}
|
||||
|
||||
private setNewActiveGitFile(activeGitFile: string | undefined): void {
|
||||
|
|
|
|||
|
|
@ -39,10 +39,13 @@ export class ReviewChangesReminderInterval extends SettingComponent {
|
|||
* Dismisses the checkpoint reminder notification if present.
|
||||
*/
|
||||
export async function dismissCheckpointReminder(
|
||||
plugin: GitChangelogPlugin
|
||||
plugin: GitChangelogPlugin,
|
||||
hide: boolean
|
||||
): Promise<void> {
|
||||
if (plugin.checkpointReminderNotice) {
|
||||
plugin.checkpointReminderNotice.hide();
|
||||
if (hide) {
|
||||
plugin.checkpointReminderNotice.hide();
|
||||
}
|
||||
plugin.checkpointReminderNotice = undefined;
|
||||
}
|
||||
await resetCheckpointReminderCounter(plugin);
|
||||
|
|
@ -67,7 +70,7 @@ export async function handleReviewChangesReminderInterval(
|
|||
): Promise<void> {
|
||||
const { reviewChangesReminderInterval } = plugin.settings;
|
||||
if (!reviewChangesReminderInterval || reviewChangesReminderInterval <= 0) {
|
||||
await dismissCheckpointReminder(plugin);
|
||||
await dismissCheckpointReminder(plugin, true);
|
||||
return;
|
||||
}
|
||||
// Don't show if already open
|
||||
|
|
@ -104,21 +107,22 @@ export function showCheckpointReminder(plugin: GitChangelogPlugin): void {
|
|||
openButton.style.marginTop = '8px';
|
||||
openButton.classList.add('mod-cta');
|
||||
openButton.addEventListener('click', () => {
|
||||
invokeAsyncSafely(() => openCompareToCheckpointView(plugin));
|
||||
invokeAsyncSafely(() => openCompareToCheckpointView(plugin, false));
|
||||
});
|
||||
const dismissButton = element.createEl('button', {
|
||||
text: 'Remind me later'
|
||||
});
|
||||
dismissButton.style.marginLeft = '8px';
|
||||
dismissButton.addEventListener('click', () => {
|
||||
invokeAsyncSafely(() => dismissCheckpointReminder(plugin));
|
||||
invokeAsyncSafely(() => dismissCheckpointReminder(plugin, false));
|
||||
});
|
||||
});
|
||||
plugin.checkpointReminderNotice = new Notice(frag, 0);
|
||||
}
|
||||
|
||||
export async function openCompareToCheckpointView(
|
||||
plugin: GitChangelogPlugin
|
||||
plugin: GitChangelogPlugin,
|
||||
hideCheckpointReminder = true
|
||||
): Promise<void> {
|
||||
// First close any existing COMPARE_REPO_STATES_VIEW views
|
||||
removeCompareVersionsView(plugin);
|
||||
|
|
@ -129,5 +133,7 @@ export async function openCompareToCheckpointView(
|
|||
{ reveal: true }
|
||||
);
|
||||
|
||||
invokeAsyncSafely(() => dismissCheckpointReminder(plugin));
|
||||
invokeAsyncSafely(() =>
|
||||
dismissCheckpointReminder(plugin, hideCheckpointReminder)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue