Skip to content

Commit

Permalink
Add option for copying troubleshooting information to clipboard
Browse files Browse the repository at this point in the history
This allows users to share relevant information when asking for support
e.g. on Discord.
  • Loading branch information
anttimaki committed Jan 28, 2025
1 parent fa7faed commit 1d33c88
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/settings-components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ import CdnProvider from '../../providers/generic/connection/CdnProvider';
'fa-clipboard',
() => this.emitInvoke('CopyLogToClipboard')
),
new SettingsRow(
'Debugging',
'Copy troubleshooting information to clipboard',
'Copy settings and other information to the clipboard, with Discord formatting.',
async () => 'Share this information when requesting support on Discord.',
'fa-clipboard',
() => this.emitInvoke('CopyTroubleshootingInfoToClipboard')
),
new SettingsRow(
'Debugging',
'Toggle download cache',
Expand Down
8 changes: 8 additions & 0 deletions src/pages/Manager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ import ModalCard from '../components/ModalCard.vue';
}
}
async copyTroubleshootingInfoToClipboard() {
const content = await this.$store.dispatch('profile/generateTroubleshootingString');
InteractionProvider.instance.copyToClipboard('```' + content + '```');
}
async changeDataFolder() {
try {
const folder = await DataFolderProvider.instance.showSelectionDialog();
Expand Down Expand Up @@ -551,6 +556,9 @@ import ModalCard from '../components/ModalCard.vue';
case "CopyLogToClipboard":
this.copyLogToClipboard();
break;
case "CopyTroubleshootingInfoToClipboard":
this.copyTroubleshootingInfoToClipboard();
break;
case "ToggleDownloadCache":
this.toggleIgnoreCache();
break;
Expand Down
4 changes: 4 additions & 0 deletions src/r2mm/manager/PackageDexieStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export async function getPackageVersionNumbers(community: string, packageName: s
return pkg.versions.map((v) => v.version_number);
}

export async function getPackageCount(community: string) {
return await db.packages.where({community}).count();
}

/**
* @param game Game (community) which package listings should be used in the lookup.
* @param dependencies Lookup targets as Thunderstore dependency strings.
Expand Down
23 changes: 23 additions & 0 deletions src/store/modules/ProfileModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ActionTree, GetterTree } from 'vuex';

import { CachedMod } from './TsModsModule';
import { State as RootState } from '../index';
import ManagerInformation from '../../_managerinf/ManagerInformation';
import R2Error from '../../model/errors/R2Error';
import ManifestV2 from '../../model/ManifestV2';
import Profile, { ImmutableProfile } from "../../model/Profile";
Expand All @@ -11,6 +12,7 @@ import { SortNaming } from '../../model/real_enums/sort/SortNaming';
import ThunderstoreCombo from '../../model/ThunderstoreCombo';
import ThunderstoreMod from '../../model/ThunderstoreMod';
import ConflictManagementProvider from '../../providers/generic/installing/ConflictManagementProvider';
import GameDirectoryResolverProvider from '../../providers/ror2/game/GameDirectoryResolverProvider';
import ProfileInstallerProvider from '../../providers/ror2/installing/ProfileInstallerProvider';
import ManagerSettings from '../../r2mm/manager/ManagerSettings';
import * as PackageDb from '../../r2mm/manager/PackageDexieStore';
Expand Down Expand Up @@ -297,6 +299,27 @@ export default {
return await PackageDb.getCombosByDependencyStrings(game, outdated, useLatestVersion);
},

async generateTroubleshootingString({dispatch, getters, rootGetters, rootState}): Promise<string> {
const steamDirectory = await GameDirectoryResolverProvider.instance.getSteamDirectory();
const steamPath = steamDirectory instanceof R2Error ? '-' : steamDirectory;
const gameDirectory = await GameDirectoryResolverProvider.instance.getDirectory(rootState.activeGame);
const gamePath = gameDirectory instanceof R2Error ? '-' : gameDirectory;
const packageCacheDate = await PackageDb.getLastPackageListUpdateTime(rootState.activeGame.internalFolderName);
const packageCacheSize = await PackageDb.getPackageCount(rootState.activeGame.internalFolderName);
const packageVuexState: string = await dispatch('tsMods/generateTroubleshootingString', null, {root: true});

const content = `
App: ${ManagerInformation.APP_NAME} v${ManagerInformation.VERSION}
Game: ${rootState.activeGame.displayName} (${rootState.activeGame.activePlatform.storePlatform})
Steam path: ${steamPath}
Game path: ${gamePath}
Profile path: ${getters.activeProfile.getProfilePath()}
Custom launch arguments: ${rootGetters.settings.getContext().gameSpecific.launchParameters || '-'}
Mod list in cache: ${packageCacheSize} mods, hash updated ${packageCacheDate || 'never'}
Mod list in memory: ${packageVuexState}
`;
return content.replace(/(\n)\s+/g, '$1'); // Remove indentation but keep newlines
},

async loadLastSelectedProfile({commit, rootGetters}): Promise<string> {
const profileName = rootGetters['settings'].getContext().gameSpecific.lastSelectedProfile;
Expand Down
4 changes: 4 additions & 0 deletions src/store/modules/TsModsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ export const TsModsModule = {
return updated !== undefined;
},

async generateTroubleshootingString({state}): Promise<string> {
return `${state.mods.length} mods, updated ${state.modsLastUpdated || 'never'}`;
},

async getActiveGameCacheStatus({commit, state, rootState}): Promise<string> {
if (state.isThunderstoreModListUpdateInProgress) {
return "Online mod list is currently updating, please wait for the operation to complete";
Expand Down

0 comments on commit 1d33c88

Please sign in to comment.