File size: 1,486 Bytes
43a06dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { get } from "svelte/store";
import { t } from "$lib/i18n/translations";
import settings, { updateSetting } from "$lib/state/settings";

import { createDialog } from "$lib/state/dialogs";

export const customInstanceWarning = async () => {
    if (get(settings).processing.seenCustomWarning) {
        return;
    }

    let _actions: {
        resolve: () => void;
        reject: () => void;
    };

    const promise = new Promise<void>(
        (resolve, reject) => (_actions = { resolve, reject })
    ).catch(() => {
        return {}
    });

    createDialog({
        id: "security-api-custom",
        type: "small",
        icon: "warn-red",
        title: get(t)("dialog.safety.title"),
        bodyText: get(t)("dialog.safety.custom_instance.body"),
        leftAligned: true,
        buttons: [
            {
                text: get(t)("button.cancel"),
                main: false,
                action: () => {
                    _actions.reject();
                },
            },
            {
                text: get(t)("button.continue"),
                color: "red",
                main: true,
                timeout: 5000,
                action: () => {
                    _actions.resolve();
                    updateSetting({
                        processing: {
                            seenCustomWarning: true,
                        },
                    })
                },
            },
        ],
    })

    await promise;
}