Skip to content

Commit

Permalink
Update version to 0.4.4 and fix importQrCodeUri function
Browse files Browse the repository at this point in the history
  • Loading branch information
ckt1031 committed Feb 7, 2024
1 parent 6cde44b commit 328447a
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 161 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"isDesktopOnly": false,
"minAppVersion": "1.0.0",
"name": "WordWise",
"version": "0.4.3"
"version": "0.4.4"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-wordwise-plugin",
"version": "0.4.3",
"version": "0.4.4",
"private": true,
"description": "Obsidian plugin for AI content generation akin to Notion AI.",
"license": "MIT",
Expand Down
28 changes: 14 additions & 14 deletions src/components/qr-code.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PluginSettings } from "@/types";
import { exportQrCodeUri } from "@/utils/settings-sharing";
import { Modal, App, Notice } from "obsidian";
import { PluginSettings } from '@/types';
import { exportQrCodeUri } from '@/utils/settings-sharing';
import { App, Modal, Notice } from 'obsidian';

export class ExportSettingsQrCodeModal extends Modal {
plugin: PluginSettings;

constructor(app: App, plugin: PluginSettings) {
constructor(app: App, plugin: PluginSettings) {
super(app);
this.plugin = plugin;
}
Expand All @@ -15,38 +15,38 @@ export class ExportSettingsQrCodeModal extends Modal {

const { rawUri, imgUri } = await exportQrCodeUri(
this.plugin,
this.app.vault.getName()
this.app.vault.getName(),
);

const div1 = contentEl.createDiv();

div1.createEl("p", {
text: "Scan the QR code with your mobile device to import the settings",
div1.createEl('p', {
text: 'Scan the QR code with your mobile device to import the settings',
});

const div2 = contentEl.createDiv();
div2.createEl(
"button",
'button',
{
text: "Copy URI",
text: 'Copy URI',
},
(el) => {
el.onclick = async () => {
await navigator.clipboard.writeText(rawUri);
new Notice("URI copied to clipboard");
new Notice('URI copied to clipboard');
};
}
},
);

const div3 = contentEl.createDiv();
div3.createEl(
"img",
'img',
{
cls: "qrcode-img",
cls: 'qrcode-img',
},
async (el) => {
el.src = imgUri;
}
},
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const COHERE_MODELS = [
];

// This key can be exposed here as the aim is only to prevent direct exposure of data through sharing.
export const QR_CODE_ENCRYPT_KEY = "DsH24E4xr8AfeZz24n6BCdew6f63";
export const QR_CODE_ENCRYPT_KEY = 'DsH24E4xr8AfeZz24n6BCdew6f63';

// Ref: https://ai.google.dev/models/gemini
// Updated on 2024-01-26
Expand Down
36 changes: 19 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,22 @@ export default class WordWisePlugin extends Plugin {
// This adds a settings tab so the user can configure various aspects of the plugin
this.addSettingTab(new SettingTab(this.app, this));

this.registerObsidianProtocolHandler(
manifest.id,
async (inputParams) => {
const parsed = importQrCodeUri(
inputParams,
this.app.vault.getName()
this.registerObsidianProtocolHandler(manifest.id, async (inputParams) => {
const parsed = importQrCodeUri(inputParams, this.app.vault.getName());
if (parsed.status === 'error') {
new Notice(parsed.message);
} else {
this.settings = Object.assign(
{},
this.settings,
await this.handleData(parsed.result),
);
this.saveSettings();
new Notice(
'Settings imported. Please check the settings tab to verify.',
);
if (parsed.status === "error") {
new Notice(parsed.message);
} else {
this.settings = Object.assign({}, this.settings, await this.handleData(parsed.result));
this.saveSettings();
new Notice(
"Settings imported. Please check the settings tab to verify."
);
}
}
);
});

log(this.settings, 'Loaded plugin.');
}
Expand Down Expand Up @@ -118,7 +116,11 @@ export default class WordWisePlugin extends Plugin {
}
const parsedData = deobfuscateConfig(localData);

this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.handleData(parsedData));
this.settings = Object.assign(
{},
DEFAULT_SETTINGS,
await this.handleData(parsedData),
);
}

async handleData(data: unknown) {
Expand Down
4 changes: 2 additions & 2 deletions src/migration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Notice } from 'obsidian';
import {
array,
boolean,
Expand All @@ -9,7 +10,6 @@ import {
} from 'valibot';
import { DEFAULT_SETTINGS } from './config';
import { APIProvider, CustomPromptSchema } from './types';
import { Notice } from 'obsidian';

const OldPluginSettingsSchemaBefore20240205 = object({
dataSchemeDate: string(),
Expand Down Expand Up @@ -49,7 +49,7 @@ export async function migrate20240205(settings: unknown) {
if (!success) {
return settings;
}

new Notice('Migrating wordwise settings to new schema');

// Migrate to new schema
Expand Down
Loading

0 comments on commit 328447a

Please sign in to comment.