Skip to content

Commit

Permalink
Fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsOnlyBinary committed Jan 13, 2025
1 parent c877d4a commit c5e012d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/components/NetworkSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>

<server-selector
:enable-custom="startupOptions.enable_custom ?? true"
:enable-custom="startupOptions.enableCustom ?? true"
:connection="network.connection"
/>

Expand Down
43 changes: 26 additions & 17 deletions src/components/ServerSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</template>
<option
v-for="(s, idx) in presetNetworks"
:key="s.name"
:key="'preset_'+idx"
:value="idx"
>{{ s.name }}</option>
</select>
Expand All @@ -30,10 +30,11 @@
{{ $t('protocol') }}
</label>
<select id="kiwi_server_proto" v-model="protocol" class="u-input">
<option value="irc">irc://</option>
<option value="ircs">ircs://</option>
<option value="ws">ws://</option>
<option value="wss">wss://</option>
<option
v-for="(s, idx) in serverProtocols"
:key="'proto_'+idx"
:value="s"
>{{ s }}://</option>
</select>
</div>

Expand Down Expand Up @@ -74,7 +75,7 @@ import * as Misc from '@/helpers/Misc';
import Logger from '@/libs/Logger';
const log = Logger.namespace('ServerSelector.vue');
const log = Logger.namespace('ServerSelector');
export default {
props: {
Expand Down Expand Up @@ -136,6 +137,9 @@ export default {
}
},
},
serverProtocols() {
return this.$state.getSetting('settings.serverProtocols') || ['irc', 'ircs', 'ws', 'wss'];
},
protocol: {
get() {
let proto = this.connection.direct ? 'ws' : 'irc';
Expand Down Expand Up @@ -180,12 +184,9 @@ export default {
}
},
},
isTLS() {
return ['ircs', 'wss'].includes(this.connection.proto);
},
},
created() {
const networkList = this.$state.setting('presetNetworks') || [];
const networkList = this.$state.getSetting('settings.presetNetworks') || [];
if (networkList) {
this.importUris(networkList);
}
Expand Down Expand Up @@ -218,13 +219,21 @@ export default {
}
},
toggleTls() {
const protocolMap = {
irc: 'ircs',
ircs: 'irc',
ws: 'wss',
wss: 'ws',
};
this.protocol = protocolMap[this.protocol];
const protocolMap = Object.fromEntries(
Object.entries({
irc: 'ircs',
ircs: 'irc',
ws: 'wss',
wss: 'ws',
}).filter(
([key, value]) => this.serverProtocols.includes(key)
&& this.serverProtocols.includes(value)
)
);
if (protocolMap[this.protocol]) {
this.protocol = protocolMap[this.protocol];
}
},
importUris(serverList) {
// [ 'freenode|irc.freenode.net:+6697', 'irc.snoonet.org:6667' ]
Expand Down
6 changes: 3 additions & 3 deletions src/components/startups/CustomServer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<server-selector
v-if="showSelector"
:enable-custom="startupOptions.enable_custom ?? true"
:enable-custom="startupOptions.enableCustom ?? true"
:show-path="true"
:connection="connection"
@selected="presetSelected=$event"
Expand Down Expand Up @@ -158,7 +158,7 @@ export default {
if (this.isFragment || this.presetSelected !== 'custom') {
return false;
}
return this.startupOptions.enable_tabs ?? true;
return this.startupOptions.enableTabs ?? true;
},
termsContent() {
const terms = this.startupOptions.termsContent;
Expand All @@ -179,7 +179,7 @@ export default {
'';
},
isNickValid() {
let nickPatternStr = this.$state.setting('startupOptions.nick_format');
let nickPatternStr = this.$state.getSetting('settings.startupOptions.nick_format');
let nickPattern = '';
if (!nickPatternStr) {
// Nicks cannot start with [0-9- ]
Expand Down

0 comments on commit c5e012d

Please sign in to comment.