X Tutup
Skip to content

Commit 13761cf

Browse files
committed
Check for game updates when viewing game page
1 parent e0ec2d1 commit 13761cf

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

src/common/actions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ export const actions = wireActions({
692692
checkForGameUpdate: action<{
693693
/** which cave to check for an update */
694694
caveId: string;
695+
suppressNotification: boolean;
695696
}>(),
696697
gameUpdateCheckStatus: action<{
697698
/** whether we're currently checking */

src/main/reactors/context-menu/build-template.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ export function gameControls(store: Store, game: Game): MenuTemplate {
127127
if (!busy) {
128128
updateAndLocalItems.push({
129129
localizedLabel: ["grid.item.check_for_update"],
130-
action: actions.checkForGameUpdate({ caveId: cave.id }),
130+
action: actions.checkForGameUpdate({
131+
caveId: cave.id,
132+
suppressNotification: false,
133+
}),
131134
});
132135
}
133136

src/main/reactors/updater.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default function (watcher: Watcher) {
114114
});
115115

116116
watcher.on(actions.checkForGameUpdate, async (store, action) => {
117-
const { caveId } = action.payload;
117+
const { caveId, suppressNotification } = action.payload;
118118
logger.info(`Looking for updates for cave ${caveId}`);
119119
const { cave } = await mcall(messages.FetchCave, { caveId });
120120

@@ -145,7 +145,9 @@ export default function (watcher: Watcher) {
145145
}
146146
}
147147

148-
dispatchUpdateNotification(store, cave, res);
148+
if (!suppressNotification) {
149+
dispatchUpdateNotification(store, cave, res);
150+
}
149151
});
150152

151153
watcher.on(actions.snoozeCave, async (store, action) => {

src/renderer/modal-widgets/ManageCave.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ class ManageCave extends React.PureComponent<Props> {
286286
dispatch(
287287
actions.closeModal({
288288
wind: ambientWind(),
289-
action: actions.checkForGameUpdate({ caveId }),
289+
action: actions.checkForGameUpdate({
290+
caveId,
291+
suppressNotification: false,
292+
}),
290293
})
291294
);
292295
};

src/renderer/pages/BrowserPage/BrowserContext/BrowserContextGame.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ class BrowserContextGame extends React.PureComponent<Props> {
6666
);
6767
}
6868

69+
componentDidMount() {
70+
const { status, dispatch } = this.props;
71+
if (!status.operation && !status.update && status.cave) {
72+
// this logic is inferred from the onClick handler
73+
// defined in MainAction
74+
dispatch(
75+
actions.checkForGameUpdate({
76+
caveId: status.cave.id,
77+
suppressNotification: true,
78+
})
79+
);
80+
}
81+
}
82+
6983
onContextMenu = (ev: React.MouseEvent<any>) => {
7084
ev.preventDefault();
7185
const { clientX, clientY } = ev;

0 commit comments

Comments
 (0)
X Tutup