Skip to content

Commit 2dac46c

Browse files
committed
fix: logic to display error/success messages.
Improve text for those messages. Signed-off-by: Camila Ayres <[email protected]>
1 parent 23f32a9 commit 2dac46c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/gui/declarativeui/fileactionsmodel.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,32 +249,42 @@ void FileActionsModel::createRequest(const int row)
249249
}
250250
const auto verb = job->stringToVerb(_fileActions.at(row).method);
251251
job->setVerb(verb);
252+
job->setProperty(rowC, row);
252253
job->start();
253254
}
254255

255256
void FileActionsModel::processRequest(const QJsonDocument &json, int statusCode)
256257
{
257-
auto message = tr("File action succeded, access your instance for the result.");
258+
const auto row = sender()->property(rowC).toInt();
259+
const auto fileAction = _fileActions.at(row).name;
260+
const auto errorMessage = tr("%1 did not succeed, please try again later. "
261+
"If you need help, contact your server administrator.",
262+
"file action error message").arg(fileAction);
258263
if (statusCode != 200) {
259264
qCWarning(lcFileActions) << "File action did not succeed for" << _localPath;
265+
setResponse({ errorMessage, _accountUrl });
266+
return;
260267
}
261268

262269
const auto root = json.object().value(QStringLiteral("root")).toObject();
270+
const auto folderForPath = FolderMan::instance()->folderForPath(_localPath);
271+
const auto remoteFolderPath = _accountUrl + folderForPath->remotePath();
272+
const auto successMessage = tr("%1 done.", "file action success message").arg(fileAction);
263273
if (root.empty()) {
264-
const auto folderForPath = FolderMan::instance()->folderForPath(_localPath);
265-
setResponse({ message, _accountUrl });
274+
setResponse({ successMessage, remoteFolderPath });
266275
return;
267276
}
277+
268278
const auto orientation = root.value(QStringLiteral("orientation")).toString();
269279
const auto rows = root.value(QStringLiteral("rows")).toArray();
270280
if (rows.empty()) {
281+
setResponse({ successMessage, remoteFolderPath });
271282
return;
272283
}
273284

274285
for (const auto &rowValue : rows) {
275286
const auto row = rowValue.toObject();
276287
const auto children = row.value("children").toArray();
277-
278288
for (const auto &childValue : children) {
279289
const auto child = childValue.toObject();
280290
setResponse({ child.value(QStringLiteral("element")).toString(),

src/gui/declarativeui/fileactionsmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public slots:
9797
static constexpr char fileIdUrlC[] = "{fileId}";
9898
static constexpr char fileIdC[] = "fileId";
9999
static constexpr char filePathC[] = "filePath";
100+
static constexpr char rowC[] = "row";
100101
};
101102

102103
}

0 commit comments

Comments
 (0)