Add option to send browser notifications
parent
b4cbd90a7d
commit
6204dca18f
|
|
@ -125,12 +125,12 @@ async function uploadPost(data: PostUploadCommandData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser.notifications) {
|
if (data.sendNotifications && browser.notifications) {
|
||||||
const createdPostUrl = getUrl(data.selectedSite.domain, "post", createdPost.id.toString());
|
const createdPostUrl = getUrl(data.selectedSite.domain, "post", createdPost.id.toString());
|
||||||
browser.notifications.create(createdPostUrl, {
|
browser.notifications.create(createdPostUrl, {
|
||||||
type: "basic",
|
type: "basic",
|
||||||
iconUrl: browser.runtime.getURL("assets/icon-128.png"),
|
iconUrl: browser.runtime.getURL("assets/icon-128.png"),
|
||||||
title: "SzuruChrome",
|
title: data.selectedSite.domain,
|
||||||
message: `Uploaded ${data.post.contentUrl}`,
|
message: `Uploaded ${data.post.contentUrl}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ export class PostUploadCommandData {
|
||||||
constructor(
|
constructor(
|
||||||
public readonly post: ScrapedPostDetails,
|
public readonly post: ScrapedPostDetails,
|
||||||
public readonly selectedSite: SzuruSiteConfig,
|
public readonly selectedSite: SzuruSiteConfig,
|
||||||
|
public readonly sendNotifications: boolean,
|
||||||
) { }
|
) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,17 @@ wnd.szc_set_config_version = (v = 0) => (cfg.value.version = v);
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 md:col-6">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" v-model="cfg.sendUploadNotifications" />
|
||||||
|
Send browser notifications after uploading
|
||||||
|
</label>
|
||||||
|
<p class="hint">
|
||||||
|
This will send a browser notification after a successful upload. Clicking the notification will open
|
||||||
|
the uploaded post in a new tab.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<span class="col-12 status-quiet">{{ versionInfo }}</span>
|
<span class="col-12 status-quiet">{{ versionInfo }}</span>
|
||||||
</div>
|
</div>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ async function upload() {
|
||||||
await ensurePostHasContentToken(szuru.value!, post, cfg);
|
await ensurePostHasContentToken(szuru.value!, post, cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmdData = new PostUploadCommandData(post, <SzuruSiteConfig>cloneDeep(selectedSite.value));
|
const cmdData = new PostUploadCommandData(post, <SzuruSiteConfig>cloneDeep(selectedSite.value), cfg.value.sendUploadNotifications);
|
||||||
const cmd = new BrowserCommand("upload_post", cmdData);
|
const cmd = new BrowserCommand("upload_post", cmdData);
|
||||||
await browser.runtime.sendMessage(cmd);
|
await browser.runtime.sendMessage(cmd);
|
||||||
} catch (ex: any) {
|
} catch (ex: any) {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ export const cfg = useStorageLocal(
|
||||||
version: 0,
|
version: 0,
|
||||||
addPageUrlToSource: true,
|
addPageUrlToSource: true,
|
||||||
alwaysUploadAsContent: false,
|
alwaysUploadAsContent: false,
|
||||||
|
sendUploadNotifications: true,
|
||||||
autoSearchSimilar: false,
|
autoSearchSimilar: false,
|
||||||
loadTagCounts: true,
|
loadTagCounts: true,
|
||||||
fetchPostInfo: true,
|
fetchPostInfo: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue