Skip to content

Commit

Permalink
Merge branch 'wip-4.0' into wip-4.0-mv3
Browse files Browse the repository at this point in the history
  • Loading branch information
tfedor committed Jun 21, 2024
2 parents d5fe03b + e691ece commit b4e1f05
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 78 deletions.
2 changes: 1 addition & 1 deletion src/js/Background/Db/Migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function upgrade(
db.createObjectStore("expiries")
.createIndex("idx_expiry", "");

db.createObjectStore("storeList", {keyPath: "id"});
db.createObjectStore("storeList");
}

export default {upgrade};
2 changes: 1 addition & 1 deletion src/js/Background/Modules/ContextMenu/ContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default class ContextMenu {
}
}

private static async update(): Promise<void> {
public static async update(): Promise<void> {
await SettingsStore;
if (!await Permissions.contains(["contextMenus"])) {
Settings.context_steam_store = false;
Expand Down
2 changes: 1 addition & 1 deletion src/js/Content/Features/Store/App/FBadgeProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class FBadgeProgress extends Feature<CApp> {

// No badge data if game doesn't have cards or not logged in
if (!data) {
throw new Error("Failed to find badges data");
return;
}

let target = document.querySelector(".rightcol.game_meta_data");
Expand Down
10 changes: 4 additions & 6 deletions src/js/Content/Features/Store/App/FReviewToggleButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@
export let reviewSection: HTMLElement;
let show: boolean = false;
let show: boolean = true;
function toggleReviews(event?: MouseEvent) {
async function toggleReviews(event?: MouseEvent) {
if (event) {
show = !show;
LocalStorage.set("show_review_section", show);
} else {
show = await LocalStorage.get("show_review_section") ?? true;
}
reviewSection.style.maxHeight = show ? "" : "0";
}
onMount(() => {
(async () => {
show = await LocalStorage.get("show_review_section") ?? true
})();
toggleReviews();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
entry[1] = enabled;
entries.set(name, entry);
for (let element of document.querySelectorAll<HTMLElement>(`[as-customizer='${name}']`)) {
for (let element of document.querySelectorAll<HTMLElement>(`[data-as-customizer='${name}']`)) {
element.classList.toggle("esi-shown", enabled);
element.classList.toggle("esi-hidden", !enabled);
}
Expand Down Expand Up @@ -87,12 +87,12 @@
onMount(() => {
init(setup);
// we need to run dynamic separately, because it checks whether [as-customizer] already exists in found nodes
// we need to run dynamic separately, because it checks whether [data-as-customizer] already exists in found nodes
if (dynamicSelector) {
let dynamic: CustomizerSetup = [];
for (const node of document.querySelectorAll<HTMLElement>(dynamicSelector)) {
if (node.closest("[as-customizer]")
|| node.querySelector("[as-customizer]")
if (node.closest("[data-as-customizer]")
|| node.querySelector("[data-as-customizer]")
|| node.style.display === "none"
) {
continue;
Expand Down
10 changes: 5 additions & 5 deletions src/js/Options/Data/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export const DefaultSettings: SettingsSchema = Object.freeze({
"exfgls": true,
"app_custom_link": [
{
"enabled": false,
"enabled": true,
"name": "Google",
"url": "google.com/search?q=[ID]+[NAME]",
"icon": "www.google.com/images/branding/product/ico/googleg_lodp.ico"
"url": "https://www.google.com/search?q=[ID]+[NAME]",
"icon": "https://www.google.com/images/branding/product/ico/googleg_lodp.ico"
},
],

Expand Down Expand Up @@ -156,8 +156,8 @@ export const DefaultSettings: SettingsSchema = Object.freeze({
{
"enabled": true,
"name": "Google",
"url": "google.com/search?q=[ID]",
"icon": "www.google.com/images/branding/product/ico/googleg_lodp.ico"
"url": "https://www.google.com/search?q=[ID]",
"icon": "https://www.google.com/images/branding/product/ico/googleg_lodp.ico"
},
],
"group_steamgifts": true,
Expand Down
38 changes: 0 additions & 38 deletions src/js/Options/Modules/Fader.js

This file was deleted.

46 changes: 28 additions & 18 deletions src/js/Options/Modules/Options/Settings/ContextMenuOptions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,66 @@
import {L} from "@Core/Localization/Localization";
import Toggle from "../Components/Toggle.svelte";
import Permissions from "@Core/Permissions";
import ContextMenu from "@Background/Modules/ContextMenu/ContextMenu";
export let settings: Writable<SettingsSchema>;
type ContextMenuKeys = keyof SettingsSchema & (
"context_steam_store"
| "context_steam_market"
| "context_itad"
| "context_bartervg"
| "context_steamdb"
| "context_steamdb_instant"
| "context_steam_keys"
);
async function handleChange(value: boolean): Promise<boolean> {
if (!value) {
return false;
}
export let settings: Writable<SettingsSchema>;
const permissions = ["contextMenus"];
const hasPermissions = await Permissions.contains(permissions);
if (hasPermissions) {
return true;
async function handleChange(key: ContextMenuKeys, value: boolean): Promise<void> {
if (value) {
const permissions = ["contextMenus"];
const hasPermissions = await Permissions.contains(permissions);
if (!hasPermissions) {
// @ts-expect-error
value = await Permissions.request(permissions);
}
}
// @ts-ignore
return Permissions.request(permissions);
$settings[key] = value;
ContextMenu.update();
}
</script>

<Toggle value={$settings.context_steam_store}
on:toggle={async (e) => $settings.context_steam_store = await handleChange(e.detail)}>
on:toggle={async (e) => handleChange("context_steam_store", e.detail)}>
{L(__options_contextSteamStore, {query: "..."})}
</Toggle>

<Toggle value={$settings.context_steam_market}
on:toggle={async (e) => $settings.context_steam_market = await handleChange(e.detail)}>
on:toggle={async (e) => handleChange("context_steam_market", e.detail)}>
{L(__options_contextSteamMarket, {query: "..."})}
</Toggle>

<Toggle value={$settings.context_itad}
on:toggle={async (e) => $settings.context_itad = await handleChange(e.detail)}>
on:toggle={async (e) => handleChange("context_itad", e.detail)}>
{L(__options_contextItad, {query: "..."})}
</Toggle>

<Toggle value={$settings.context_bartervg}
on:toggle={async (e) => $settings.context_bartervg = await handleChange(e.detail)}>
on:toggle={async (e) => handleChange("context_bartervg", e.detail)}>
{L(__options_contextBartervg, {query: "..."})}
</Toggle>

<Toggle value={$settings.context_steamdb}
on:toggle={async (e) => $settings.context_steamdb = await handleChange(e.detail)}>
on:toggle={async (e) => handleChange("context_steamdb", e.detail)}>
{L(__options_contextSteamdb, {query: "..."})}
</Toggle>

<Toggle value={$settings.context_steamdb_instant}
on:toggle={async (e) => $settings.context_steamdb_instant = await handleChange(e.detail)}>
on:toggle={async (e) => handleChange("context_steamdb_instant", e.detail)}>
{L(__options_contextSteamdbInstant, {query: "..."})}
</Toggle>

<Toggle value={$settings.context_steam_keys}
on:toggle={async (e) => $settings.context_steam_keys = await handleChange(e.detail)}>
on:toggle={async (e) => handleChange("context_steam_keys", e.detail)}>
{L(__options_contextSteamKeys)}
</Toggle>
14 changes: 11 additions & 3 deletions src/js/Options/Modules/Options/Settings/CustomLinks.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options immutable={false} />

<script lang="ts">
import {__options_addCustomLink, __options_icon, __options_name} from "@Strings/_strings";
import {onMount} from "svelte";
Expand All @@ -15,7 +17,6 @@
function removeLink(index: number): void {
customLinks.splice(index, 1);
customLinks = customLinks;
save();
}
Expand All @@ -26,10 +27,17 @@
url: "",
icon: ""
});
customLinks = customLinks;
save();
}
function toggleLink(link: TCustomLink): void {
link.enabled = !link.enabled;
save();
}
function save(): void {
customLinks = customLinks;
if (type === "app") {
Settings.app_custom_link = customLinks;
} else {
Expand All @@ -50,7 +58,7 @@
{#each customLinks as link, index (link)}
<div class="box" on:change={save} transition:slide={{axis: "y", duration: 200}}>
<div class="controls">
<button type="button" class="toggle" on:click={() => link.enabled = !link.enabled}>
<button type="button" class="toggle" on:click={() => toggleLink(link)}>
<ToggleIcon on={link.enabled} />
</button>

Expand Down
2 changes: 2 additions & 0 deletions src/js/Options/Modules/Options/Settings/RegionSelect.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options immutable={false} />

<script lang="ts">
import {
__always, __never,
Expand Down
18 changes: 17 additions & 1 deletion src/js/Options/Modules/Options/Settings/StoreListSetting.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options immutable={false} />

<script lang="ts">
import ITADApiFacade from "@Content/Modules/Facades/ITADApiFacade";
import {onMount} from "svelte";
Expand All @@ -15,6 +17,18 @@
let promise: Promise<TGetStoreListResponse>|null = null;
let excludedStores: SettingsSchema['excluded_stores'] = [];
function toggle(id: number) {
let set = new Set(excludedStores);
if (set.has(id)) {
set.delete(id);
} else {
set.add(id);
}
excludedStores = [...set];
$settings.excluded_stores = excludedStores;
}
onMount(() => {
promise = (async () => {
try {
Expand All @@ -41,7 +55,9 @@
{#each storeList as {id, title} (id)}
<div class="store">
<label>
<input type="checkbox" checked={!excludedStores.includes(id)}>
<input type="checkbox"
checked={!excludedStores.includes(id)}
on:change={() => toggle(id)}>
{title}
</label>
</div>
Expand Down

0 comments on commit b4e1f05

Please sign in to comment.