Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
34a6a1b
commit c83bf14
Showing
15 changed files
with
156 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
import invariant from 'invariant' | ||
|
||
import urls from '../constants/urls' | ||
|
||
import {getUserMarket} from './market' | ||
import fetch from '../util/fetch' | ||
|
||
import localizer from '../localizer' | ||
import {shell, dialog} from '../electron' | ||
|
||
async function showPackagingPolicy (store, action) { | ||
const {format, gameId} = action.payload | ||
invariant(typeof format === 'string', 'showPackagingPolicy has string format') | ||
invariant(typeof gameId === 'number', 'showPackagingPolicy has game id') | ||
|
||
const i18n = store.getState().i18n | ||
const t = localizer.getT(i18n.strings, i18n.lang) | ||
|
||
const credentials = store.getState().session.credentials | ||
const market = getUserMarket() | ||
|
||
const game = await fetch.gameLazily(market, credentials, gameId) | ||
if (!game) { | ||
throw new Error(`unknown game id ${gameId}, can't show policy`) | ||
} | ||
|
||
const buttons = [ | ||
t('prompt.action.ok'), | ||
t('prompt.packaging_policy.learn_more'), | ||
t('prompt.packaging_policy.open_web_page', {title: game.title}) | ||
] | ||
|
||
const dialogOpts = { | ||
type: 'error', | ||
buttons, | ||
title: t(`prompt.${format}_policy.title`), | ||
message: t(`prompt.${format}_policy.message`, {title: game.title}), | ||
detail: t(`prompt.${format}_policy.detail`) | ||
} | ||
|
||
const callback = (response) => { | ||
// not much to do anyway. | ||
if (response === 1) { | ||
shell.openExternal(urls[`${format}Policy`]) | ||
} else if (response === 2) { | ||
shell.openExternal(game.url) | ||
} | ||
} | ||
dialog.showMessageBox(dialogOpts, callback) | ||
} | ||
|
||
export default {showPackagingPolicy} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.