revenge-plugins/better-timestamps/install/index.js
2026-08-01 15:40:02 +00:00

1 line
3.1 KiB
JavaScript

(function(o,g,r,y,a,i,h,p){"use strict";function v(e,t,s,n){try{return s()}catch(c){return n.error(`[${e}] Failed to apply the "${t}" patch, that surface will be skipped: ${c}`),function(){}}}function M(e,t,s){const n=Object.entries(s).map(function([c,C]){return v(e,c,C,t)});return function(){return n.forEach(function(c){return c()})}}function u(e,t=r.storage.selected){try{switch(t){case"calendar":return e.calendar();case"relative":return e.fromNow();case"iso":return e.toISOString();case"custom":return e.format(r.storage.customFormat||"dddd, MMMM Do YYYY, h:mm:ss a");default:return e.calendar()}}catch{return e?.calendar?.()??String(e)}}const l=y.findByName("RowManager",!1);function R(){if(!l?.prototype?.generate)return function(){};const e=[];return e.push(i.before("generate",l.prototype,function([t]){try{t.rowType===1?(r.storage.separateMessages&&(t.isFirst=!0),t.message.__customTimestamp=u(t.message.timestamp)):t.rowType==="day"&&(t.text=u(a.moment(t.text,"LL")))}catch{}})),e.push(i.after("generate",l.prototype,function([t],s){try{if(t.rowType!==1)return;t.message?.__customTimestamp&&s?.message?.state==="SENT"&&s.message.timestamp&&(s.message.timestamp=t.message.__customTimestamp)}catch{}})),function(){return e.forEach(function(t){return t()})}}const{ScrollView:b,View:w}=a.ReactNative;function E({children:e}){return a.React.createElement(b,{style:{flex:1}},e,a.React.createElement(w,{style:{height:24}}))}const{Text:F}=a.ReactNative,{FormSection:m,FormRow:k,FormDivider:Y,FormSwitchRow:S,FormInput:T}=p.Forms,d=[{label:"Calendar",key:"calendar"},{label:"Relative",key:"relative"},{label:"ISO 8601",key:"iso"},{label:"Custom",key:"custom"}];function _(){return h.useProxy(r.storage),a.React.createElement(E,null,a.React.createElement(m,{title:"Format"},d.map(function(e,t){const s=r.storage.selected===e.key;let n="";try{n=u(a.moment(),e.key)}catch{n=""}return a.React.createElement(a.React.Fragment,{key:e.key},a.React.createElement(k,{label:e.label,subLabel:n,trailing:s?a.React.createElement(F,{style:{fontSize:16}},"\u2713"):void 0,onPress:function(){r.storage.selected=e.key}}),e.key==="custom"&&s&&a.React.createElement(T,{title:"Custom format (moment.js tokens)",placeholder:"dddd, MMMM Do YYYY, h:mm:ss a",value:r.storage.customFormat,onChange:function(c){r.storage.customFormat=c}}),t!==d.length-1&&a.React.createElement(Y,null))})),a.React.createElement(m,{title:"Layout"},a.React.createElement(S,{label:"Always show name & avatar",subLabel:"Shows the username, avatar, and timestamp on every message instead of grouping consecutive messages",value:!!r.storage.separateMessages,onValueChange:function(e){r.storage.separateMessages=e}})))}let f=function(){};var L={onLoad:function(){r.storage.selected??="calendar",r.storage.customFormat??="dddd, MMMM Do YYYY, h:mm:ss a",r.storage.separateMessages??=!1,f=M("BetterTimestamps",g.logger,{"message & day timestamps":R})},onUnload:function(){return f()},settings:_};return o.default=L,Object.defineProperty(o,"__esModule",{value:!0}),o})({},vendetta,vendetta.plugin,vendetta.metro,vendetta.metro.common,vendetta.patcher,vendetta.storage,vendetta.ui.components);