Add option to send browser notifications
parent
5101c79c59
commit
be2afe55ff
|
|
@ -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());
|
||||
browser.notifications.create(createdPostUrl, {
|
||||
type: "basic",
|
||||
iconUrl: browser.runtime.getURL("assets/icon-128.png"),
|
||||
title: "SzuruChrome",
|
||||
title: data.selectedSite.domain,
|
||||
message: `Uploaded ${data.post.contentUrl}`,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ export class PostUploadCommandData {
|
|||
constructor(
|
||||
public readonly post: ScrapedPostDetails,
|
||||
public readonly selectedSite: SzuruSiteConfig,
|
||||
public readonly sendNotifications: boolean,
|
||||
) { }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,17 @@ wnd.szc_set_config_version = (v = 0) => (cfg.value.version = v);
|
|||
</p>
|
||||
</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>
|
||||
</div>
|
||||
</TabPanel>
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ async function upload() {
|
|||
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);
|
||||
await browser.runtime.sendMessage(cmd);
|
||||
} catch (ex: any) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export const cfg = useStorageLocal(
|
|||
version: 0,
|
||||
addPageUrlToSource: true,
|
||||
alwaysUploadAsContent: false,
|
||||
sendUploadNotifications: true,
|
||||
autoSearchSimilar: false,
|
||||
loadTagCounts: true,
|
||||
fetchPostInfo: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue