Skip to content

Commit

Permalink
No longer displays cloud sync icon when opting out of online backups
Browse files Browse the repository at this point in the history
  • Loading branch information
m committed Aug 29, 2021
1 parent 9c134ed commit 7b797d4
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 21,681 deletions.
5 changes: 5 additions & 0 deletions IAGrim/UI/MainWindow.cs
Expand Up @@ -133,6 +133,7 @@ public partial class MainWindow : Form {

var settingsService = _serviceProvider.Get<SettingsService>();
_cefBrowserHandler.SetDarkMode(settingsService.GetPersistent().DarkMode);
_cefBrowserHandler.SetOnlineBackupsEnabled(!settingsService.GetLocal().OptOutOfBackups);
}
}
}
Expand Down Expand Up @@ -594,6 +595,10 @@ ParsingService parsingService
_cefBrowserHandler.SetDarkMode(settingsService.GetPersistent().DarkMode);
}

settingsService.GetLocal().OnMutate += delegate(object o, EventArgs args) { _cefBrowserHandler.SetOnlineBackupsEnabled(!settingsService.GetLocal().OptOutOfBackups); };



Logger.Debug("UI initialization complete");
}

Expand Down
15 changes: 9 additions & 6 deletions IAGrim/UI/Misc/CEF/CefBrowserHandler.cs
Expand Up @@ -135,17 +135,20 @@ public class CefBrowserHandler : IDisposable, ICefBackupAuthentication, IUserFee
}
}

private class QuickTimeoutWebClient : WebClient {
protected override WebRequest GetWebRequest(Uri uri) {
WebRequest w = base.GetWebRequest(uri);
w.Timeout = 500;
return w;
public bool SetOnlineBackupsEnabled(bool enabled) {
if (BrowserControl.CanExecuteJavascriptInMainFrame) {
BrowserControl.ExecuteScriptAsync("window.setOnlineBackupsEnabled", enabled);
return true;
} else {
Logger.Warn("Attempted to set dark/light mode but CEF not yet initialized.");
return false;
}
}


private string GetSiteUri() {
#if DEBUG
var client = new QuickTimeoutWebClient();
var client = new WebClient();

try {
Logger.Debug("Checking if NodeJS is running...");
Expand Down
21,453 changes: 46 additions & 21,407 deletions WebUi/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion WebUi/package.json
Expand Up @@ -20,7 +20,7 @@
},
"scripts": {
"start": "cross-env REACT_APP_BUILD_TARGET=GDIA react-scripts start",
"start:online": "cross-env REACT_APP_BUILD_TARGET=ONLINE REACT_APP_SERVER_URL=http://localhost:8080 react-scripts start",
"dev": "cross-env REACT_APP_BUILD_TARGET=GDIA react-scripts start",
"start:help": "cross-env REACT_APP_BUILD_TARGET=HELP react-scripts start",
"build": "react-scripts build",
"build:online": "cross-env REACT_APP_BUILD_TARGET=ONLINE react-scripts build",
Expand Down
10 changes: 10 additions & 0 deletions WebUi/src/App.tsx
Expand Up @@ -24,6 +24,7 @@ export interface ApplicationState {
isDarkMode: boolean;
helpSearchFilter: string;
numItems: number;
showBackupCloudIcon: boolean;
}


Expand Down Expand Up @@ -67,6 +68,7 @@ class App extends React.PureComponent<{}, object> {
isDarkMode: false,
helpSearchFilter: '',
numItems: 0,
showBackupCloudIcon: true,
} as ApplicationState;

componentDidMount() {
Expand Down Expand Up @@ -144,6 +146,13 @@ class App extends React.PureComponent<{}, object> {
});
};

// @ts-ignore:
window.setOnlineBackupsEnabled = (enabled: boolean) => {
this.setState({
showBackupCloudIcon: enabled
});
};

// Show a notification message such as "Item transferred" or "Too close to stash"
// @ts-ignore: showMessage doesn't exist on window
window.showMessage = (input: string) => {
Expand Down Expand Up @@ -202,6 +211,7 @@ class App extends React.PureComponent<{}, object> {
{this.state.activeTab === 3 && <CharacterListContainer />}

{this.state.activeTab === 0 && <ItemContainer
showBackupCloudIcon={this.state.showBackupCloudIcon}
items={this.state.items}
numItems={this.state.numItems}
isLoading={this.state.isLoading}
Expand Down
88 changes: 0 additions & 88 deletions WebUi/src/OnlineApp.css

This file was deleted.

164 changes: 0 additions & 164 deletions WebUi/src/OnlineApp.tsx

This file was deleted.

5 changes: 3 additions & 2 deletions WebUi/src/components/Item/Item.tsx
Expand Up @@ -19,6 +19,7 @@ interface Props {
transferAll: (x: any) => void;
getItemName: (baseRecord: string) => ICollectionItem;
requestUnknownItemHelp: () => void;
showBackupCloudIcon: boolean;
}

export function getUniqueId(item: IItem): string {
Expand All @@ -35,7 +36,7 @@ class Item extends React.PureComponent<Props, object> {
}

openItemSite() {
openUrl(`http://www.grimtools.com/db/search?src=itemassistant&query=${this.stripColorCodes(this.props.item.name)}`);
openUrl(`https://www.grimtools.com/db/search?src=itemassistant&query=${this.stripColorCodes(this.props.item.name)}`);
}

renderBuddyItem(item: IItem) {
Expand Down Expand Up @@ -181,7 +182,7 @@ class Item extends React.PureComponent<Props, object> {
: ''
}

<ItemCornerContainer {...item} />
<ItemCornerContainer {...item} showBackupCloudIcon={this.props.showBackupCloudIcon} />

{item.hasRecipe && item.type === IItemType.Recipe ?
<div className="recipe-item">
Expand Down
13 changes: 10 additions & 3 deletions WebUi/src/components/Item/ItemCornerContainer.tsx
Expand Up @@ -4,11 +4,18 @@ import { isEmbedded } from '../../integration/integration';
import translate from '../../translations/EmbeddedTranslator';
import IItemType from '../../interfaces/IItemType';

class ItemCornerContainer extends React.PureComponent<IItem, object> {

interface Props {
showBackupCloudIcon: boolean;
}
type IItemWithshowBackupCloudIcon = Props & IItem;

class ItemCornerContainer extends React.PureComponent<IItemWithshowBackupCloudIcon, object> {
render() {
const item = {...this.props};
const showCloudOkIcon = item.type === IItemType.Player && item.hasCloudBackup && isEmbedded;
const showCloudErrorIcon = item.type === IItemType.Player && !item.hasCloudBackup && isEmbedded;
const showBackupCloudIcon = item.showBackupCloudIcon;
const showCloudOkIcon = item.type === IItemType.Player && item.hasCloudBackup && isEmbedded && showBackupCloudIcon;
const showCloudErrorIcon = item.type === IItemType.Player && !item.hasCloudBackup && isEmbedded && showBackupCloudIcon;
const showSingularBuddyItemIcon = item.type !== IItemType.Buddy && item.buddies.length === 1;
const showPluralBuddyItemIcon = item.type !== IItemType.Buddy && item.buddies.length > 1;
const showRecipeIcon = item.hasRecipe && item.type !== 0;
Expand Down

0 comments on commit 7b797d4

Please sign in to comment.