Skip to content

Commit

Permalink
update minAppVersion to 1.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Jun 12, 2024
1 parent 180fe4a commit e64b923
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifest-beta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "pdf-plus",
"name": "PDF++",
"version": "0.40.6",
"minAppVersion": "1.4.16",
"minAppVersion": "1.5.8",
"description": "The most Obsidian-native PDF annotation tool ever.",
"author": "Ryota Ushio",
"authorUrl": "https://github.com/RyotaUshio",
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "pdf-plus",
"name": "PDF++",
"version": "0.40.6",
"minAppVersion": "1.4.16",
"minAppVersion": "1.5.8",
"description": "The most Obsidian-native PDF annotation tool ever.",
"author": "Ryota Ushio",
"authorUrl": "https://github.com/RyotaUshio",
Expand Down
8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import { ColorPalette } from 'color-palette';
import { DomManager } from 'dom-manager';
import { PDFCroppedEmbed } from 'pdf-cropped-embed';
import { DEFAULT_SETTINGS, PDFPlusSettings, PDFPlusSettingTab } from 'settings';
import { subpathToParams, OverloadParameters, focusObsidian, isTargetHTMLElement } from 'utils';
import { subpathToParams, OverloadParameters, focusObsidian, isTargetHTMLElement, getInstallerVersion, isVersionOlderThan } from 'utils';
import { DestArray, ObsidianViewer, PDFEmbed, PDFView, PDFViewerChild, PDFViewerComponent, Rect } from 'typings';
import { ExternalPDFModal } from 'modals';
import { PDFExternalLinkPostProcessor, PDFInternalLinkPostProcessor, PDFOutlineItemPostProcessor, PDFThumbnailItemPostProcessor } from 'post-process';
import { BibliographyManager } from 'bib';
import { InstallerVersionModal } from 'modals/installer-version-modal';


export default class PDFPlus extends Plugin {
Expand Down Expand Up @@ -134,6 +135,11 @@ export default class PDFPlus extends Plugin {
if (requireApiVersion(untestedVersion)) {
console.warn(`${this.manifest.name}: This plugin has not been tested on Obsidian ${untestedVersion} or above. Please report any issue you encounter on GitHub (https://github.com/RyotaUshio/obsidian-pdf-plus/issues/new/choose).`);
}

const installerVersion = getInstallerVersion();
if (installerVersion && isVersionOlderThan(installerVersion, '1.5.8')) {
new InstallerVersionModal(this).open();
}
}

private addIcons() {
Expand Down
29 changes: 29 additions & 0 deletions src/modals/installer-version-modal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ButtonComponent } from 'obsidian';
import { PDFPlusModal } from './base-modal';


export class InstallerVersionModal extends PDFPlusModal {
onOpen() {
super.onOpen();

const name = this.plugin.manifest.name;
this.setTitle(`${name}: Outdated Obsidian installer`);
this.contentEl.appendText(
`Your Obsidian installer is outdated and likely to be incompatible with the latest ${name}. Please download the latest installer from Obsidian's website and re-install the Obsidian app.`
);

this.contentEl.createDiv('modal-button-container', (el) => {
new ButtonComponent(el)
.setButtonText('Get installer from https://obsidian.md')
.setCta()
.onClick(() => {
window.open('https://obsidian.md/download', '_blank');
});
new ButtonComponent(el)
.setButtonText('What is "installer version"?')
.onClick(() => {
window.open('https://help.obsidian.md/Getting+started/Update+Obsidian#Installer%20updates', '_blank');
});
});
}
}
11 changes: 11 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ export function isVersionNewerThan(a: string, b: string) {
return a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }) === 1;
}

export function isVersionOlderThan(a: string, b: string) {
return isVersionNewerThan(b, a);
}

export function getInstallerVersion(): string | null {
return Platform.isDesktopApp ?
// @ts-ignore
window.electron.remote.app.getVersion() :
null;
}

export function findReferenceCache(cache: CachedMetadata, start: number, end: number): ReferenceCache | undefined {
return cache.links?.find((link) => start <= link.position.start.offset && link.position.end.offset <= end)
?? cache.embeds?.find((embed) => start <= embed.position.start.offset && embed.position.end.offset <= end);
Expand Down

0 comments on commit e64b923

Please sign in to comment.