Skip to content

Commit 1d181a0

Browse files
committed
Refactoring
1 parent c426dc1 commit 1d181a0

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

src/backend/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,11 @@ export const synchronizeMutation = gql`
204204
export const applySyncMutation = gql`
205205
mutation ApplySync(
206206
$perspectiveId: LingvodocID!
207-
$foreignChanges: ObjectVal!
208207
$remote: String!
209208
$debugFlag: Boolean
210209
) {
211210
apply_sync(
212211
perspective_id: $perspectiveId
213-
foreign_changes: $foreignChanges
214212
remote: $remote
215213
debug_flag: $debugFlag) {
216214
message

src/components/SyncModal/index.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,25 @@ const SyncModal = ({ columns, onClose, perspectiveId, foreignChanges }) => {
2222
onCompleted: ({ list_changes: ispSyncData }) => {
2323
setIspSyncData(ispSyncData);
2424
console.log(`Possible errors: ${ispSyncData.errors}`);
25-
}
25+
},
26+
fetchPolicy: "network-only"
2627
});
2728

2829
const { error: xalSyncError, loading: xalSyncLoading } = useQuery(queryListChanges, {
2930
variables: { remote: "xal", perspectiveId },
3031
onCompleted: ({ list_changes: xalSyncData }) => {
3132
setXalSyncData(xalSyncData);
3233
console.log(`Possible errors: ${xalSyncData.errors}`);
33-
}
34+
},
35+
fetchPolicy: "network-only"
3436
});
3537

36-
const [applyIspSync, { error: errorIspApply, loading: loadingIspApply }] = useMutation(
38+
const [applySync, { error: errorApply, loading: loadingApply }] = useMutation(
3739
applySyncMutation, {
38-
variables: { perspectiveId, foreignChanges: xalSyncData, remote: 'isp', debugFlag: true },
40+
variables: { perspectiveId, remote: 'xal', debugFlag: true },
3941
//onCompleted: data => setXlsxUrl(data?.twins_xlsx)
4042
});
4143

42-
const [applyXalSync, { error: errorXalApply, loading: loadingXalApply }] = useMutation(
43-
applySyncMutation, {
44-
variables: { perspectiveId, foreignChanges: ispSyncData, remote: 'xal', debugFlag: true },
45-
//onCompleted: data => setXlsxUrl(data?.twins_xlsx)
46-
});
47-
48-
const applySync = () => {
49-
applyIspSync();
50-
applyXalSync();
51-
};
52-
5344
const dataCore = {
5445
languages: [
5546
["2025-11-15", "2025-11-16", { id: "1", text: "Some text" }],
@@ -294,10 +285,31 @@ const SyncModal = ({ columns, onClose, perspectiveId, foreignChanges }) => {
294285
</div>
295286
</div>
296287
<Button
297-
content={getTranslation("Apply")}
298-
onClick={applySync}
288+
content={
289+
(ispSyncLoading || xalSyncLoading) ? (
290+
<span>
291+
{getTranslation("Loading")}... <Icon name="spinner" loading />
292+
</span>
293+
) : loadingApply ? (
294+
<span>
295+
{getTranslation("Applying")}... <Icon name="spinner" loading />
296+
</span>
297+
) : getTranslation("Apply")
298+
}
299+
onClick={
300+
() => {
301+
applySync();
302+
onClose();
303+
}
304+
}
299305
//loading={loadingApply}
300-
//disabled={errorApply}
306+
disabled={
307+
ispSyncLoading ||
308+
xalSyncLoading ||
309+
ispSyncError ||
310+
xalSyncError ||
311+
loadingApply
312+
}
301313
className="lingvo-button-greenest lingvo-button-greenest_sync"
302314
/>
303315

0 commit comments

Comments
 (0)